Skip sub-RTXes of the memory operand if stack access register is
not mentioned in the operand.

gcc/ChangeLog:

    * config/i386/i386.cc (ix86_update_stack_alignment): Skip sub-RTXes
    of the memory operand if stack access register is not mentioned in
    the operand.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Uros.
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index ae2386785af..bfd9cac215a 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -8495,13 +8495,18 @@ ix86_update_stack_alignment (rtx, const_rtx pat, void 
*data)
   FOR_EACH_SUBRTX (iter, array, pat, ALL)
     {
       auto op = *iter;
-      if (MEM_P (op) && reg_mentioned_p (p->reg, op))
+      if (MEM_P (op))
        {
-         unsigned int alignment = MEM_ALIGN (op);
+         if (reg_mentioned_p (p->reg, XEXP (op, 0)))
+           {
+             unsigned int alignment = MEM_ALIGN (op);
 
-         if (alignment > *p->stack_alignment)
-           *p->stack_alignment = alignment;
-         break;
+             if (alignment > *p->stack_alignment)
+               *p->stack_alignment = alignment;
+             break;
+           }
+         else
+           iter.skip_subrtxes ();
        }
     }
 }

Reply via email to