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

--- Comment #27 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Ilya Enkovich from comment #26)
> (In reply to H.J. Lu from comment #25)
> > Please add -mpreferred-stack-boundary=2 to your tests.  Otherwise,
> > you just remove a nop.
> 
> Here is a test which crashes LRA with the path you proposed.  Crash happens
> because LRA requests a stack slot aligned by 8 and stack is aligned by 4. 
> So Jakub's patch looks the safest option for now, but probably use 64
> requirement instead of 128.
> 
> >cat test.i
> long long a, b;
> fn1() {
>   long long c = a;
>   a = b ^ a;
>   fn2();
>   a = c;
> }
> >gcc test.i -O2 -m32 -mpreferred-stack-boundary=2
> test.i: In function 'fn1':
> test.i:5:3: warning: implicit declaration of function 'fn2'
> [-Wimplicit-function-declaration]
>    fn2();
>    ^~~
> 
> test.i:7:1: internal compiler error: in assign_stack_local_1, at
> function.c:409

The last place to update stack alignment is ix86_update_stack_boundary.
Try

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a03a515..10a00f8 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3588,16 +3588,6 @@ convert_scalars_to_vector ()
   bitmap_obstack_release (NULL);
   df_process_deferred_rescans ();

-  /* Conversion means we may have 128bit register spills/fills
-     which require aligned stack.  */
-  if (converted_insns)
-    {
-      if (crtl->stack_alignment_needed < 128)
-       crtl->stack_alignment_needed = 128;
-      if (crtl->stack_alignment_estimated < 128)
-       crtl->stack_alignment_estimated = 128;
-    }
-
   return 0;
 }

@@ -12041,6 +12031,13 @@ ix86_update_stack_boundary (void)
       if (crtl->stack_alignment_needed < 128)
        crtl->stack_alignment_needed = 128;
     }
+
+  /* The STV pass needs 64-bit stack alignment.  */
+  if (!TARGET_64BIT
+      && TARGET_STV
+      && TARGET_SSE2 && optimize > 1
+      && crtl->stack_alignment_estimated < 64)
+    crtl->stack_alignment_estimated = 64;
 }

 /* Handle the TARGET_GET_DRAP_RTX hook.  Return NULL if no DRAP is

Reply via email to