[Bug rtl-optimization/91137] [7/8/9/10 Regression] Wrong code with -O3

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jul 11 08:36:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91137

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think the issue is

inv_expr 5:     ((signed long) &d + 19600) - (signed long) &c

I hope Bin can investigate this.  In the end we can only fight the RTL
alias analysis issue with heuristics here though...

We're fearing compile-time issues from a fix like the following, but
ultimatively find_base_term is known broken for a _looooong_ time.

Index: gcc/alias.c
===================================================================
--- gcc/alias.c (revision 273355)
+++ gcc/alias.c (working copy)
@@ -2003,16 +2003,20 @@ find_base_term (rtx x, vec<std::pair<cse
           term is from a pointer or is a named object or a special address
           (like an argument or stack reference), then use it for the
           base term.  */
-       rtx base = find_base_term (tmp1, visited_vals);
-       if (base != NULL_RTX
-           && ((REG_P (tmp1) && REG_POINTER (tmp1))
-                || known_base_value_p (base)))
-         return base;
-       base = find_base_term (tmp2, visited_vals);
-       if (base != NULL_RTX
-           && ((REG_P (tmp2) && REG_POINTER (tmp2))
-                || known_base_value_p (base)))
-         return base;
+       rtx base1 = find_base_term (tmp1, visited_vals);
+       if (!(base1 != NULL_RTX
+             && ((REG_P (tmp1) && REG_POINTER (tmp1))
+                 || known_base_value_p (base1))))
+         base1 = NULL_RTX;
+       rtx base2 = find_base_term (tmp2, visited_vals);
+       if (!(base2 != NULL_RTX
+             && ((REG_P (tmp2) && REG_POINTER (tmp2))
+                 || known_base_value_p (base2))))
+         base2 = NULL_RTX;
+       if (base1 && !base2)
+         return base1;
+       if (!base1 && base2)
+         return base2;

        /* We could not determine which of the two operands was the
           base register and which was the index.  So we can determine


More information about the Gcc-bugs mailing list