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

Peter Bergner <bergner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |segher at gcc dot gnu.org
          Component|target                      |rtl-optimization

--- Comment #5 from Peter Bergner <bergner at gcc dot gnu.org> ---
Looking into this more, it seems the problem is that CSE creates a constant
address and does not wrap it with a (const: ...).  If the constant address does
have a (const: ) wrapper, then decompose_address handles this just fine.  I can
modify the test case such that combine can combine our bswap load with a
following insn and combine will call simplify_binary_operation on the address
and it will create the (const: ) for us.  CSE should probably do the same when
it creates a constant address.

The following patch fixes the ICE for me.  I'll run it through bootstrap and
regtesting.

diff --git a/gcc/cse.c b/gcc/cse.c
index 5aaba8d80e0..870e2a21dbd 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -6328,6 +6328,14 @@ cse_process_notes (rtx x, rtx object, bool *changed)
   rtx new_rtx = cse_process_notes_1 (x, object, changed);
   if (new_rtx != x)
     *changed = true;
+  if (*changed && object != NULL_RTX && MEM_P (object))
+    {
+      /* Call simplify_rtx on the updated address in case it is now
+        a constant and needs to be wrapped with a (const: ...).  */
+      rtx simplified_rtx = simplify_rtx (new_rtx);
+      if (simplified_rtx)
+       new_rtx = simplified_rtx;
+    }
   return new_rtx;
 }

Reply via email to