The following adjusts the find_base_{term,value} heuristic when
looking through ANDs to the case where it is obviously not
aligning a base (when the LSB is set).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-11-18  Richard Biener  <rguent...@suse.de>

        PR rtl-optimization/92462
        * alias.c (find_base_term): Restrict the look through ANDs.
        (find_base_value): Likewise.

Index: gcc/alias.c
===================================================================
--- gcc/alias.c (revision 278293)
+++ gcc/alias.c (working copy)
@@ -1464,9 +1464,11 @@ find_base_value (rtx src)
       return find_base_value (XEXP (src, 1));
 
     case AND:
-      /* If the second operand is constant set the base
-        address to the first operand.  */
-      if (CONST_INT_P (XEXP (src, 1)) && INTVAL (XEXP (src, 1)) != 0)
+      /* Look through aligning ANDs.  And AND with zero or one with
+         the LSB set isn't one (see for example PR92462).  */
+      if (CONST_INT_P (XEXP (src, 1))
+         && INTVAL (XEXP (src, 1)) != 0
+         && (INTVAL (XEXP (src, 1)) & 1) == 0)
        return find_base_value (XEXP (src, 0));
       return 0;
 
@@ -2024,7 +2026,11 @@ find_base_term (rtx x, vec<std::pair<cse
       }
 
     case AND:
-      if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) != 0)
+      /* Look through aligning ANDs.  And AND with zero or one with
+         the LSB set isn't one (see for example PR92462).  */
+      if (CONST_INT_P (XEXP (x, 1))
+         && INTVAL (XEXP (x, 1)) != 0
+         && (INTVAL (XEXP (x, 1)) & 1) == 0)
        return find_base_term (XEXP (x, 0), visited_vals);
       return 0;
 

Reply via email to