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

--- Comment #4 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> I need additional -march=x86-64 to trigger this.
> I'd say either we have to pessimistically assume what the STV pass might be
> doing already during expansion, or the STV pass would need to perform parts
> of what expand_stack_alignment is doing (basically check if what the STV
> pass created causes any differences in decision during
> expand_stack_alignment, and if yes, tweak things so that the end result
> looks as if those decisions were done already during the expansion (STV is
> pre-RA pass, so maybe it still could work), or maybe easiest fix is for now
> disable TARGET_STV if preferred_stack_boundary is smaller than 4.

Looking into expand_stack_alignment I see we may need to allocate DRAP register
and make  fixup_tail_calls call.  Isn't it too late for that?  Couldn't we make
some optimizations basing on notes fixup_tail_calls invalidates?

I propose this change in STV gate:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 34b57a4..fb11680 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3661,7 +3661,11 @@ public:
   /* opt_pass methods: */
   virtual bool gate (function *)
     {
-      return !TARGET_64BIT && TARGET_STV && TARGET_SSE2 && optimize > 1;
+      return !TARGET_64BIT && TARGET_STV && TARGET_SSE2 && optimize > 1
+       /* Check we don't need to allocate DRAP register for STV.  */
+       && (crtl->drap_reg
+           || !crtl->need_drap
+           || INCOMING_STACK_BOUNDARY >= 128);
     }

   virtual unsigned int execute (function *)

Reply via email to