Hi!

The following patch attempts to fix one of the several issues with
the r266345 commit.  assign_stack_local isn't called just during expansion,
but also during RA, at which point we can't just randomly emit insns in the
middle of nowhere hoping it will be emitted in some insn sequence.

This patch just reverts the behavior for the over-aligned temporaries to
what we did before if it isn't during RA.  If needed, for GCC10 we can come
up with a way to tell the RA that it should realign, but IMHO it isn't
really needed right now.

Bootstrapped/regtested on x86_64-linux, i686-linux and powerpc64le-linux, ok
for trunk?

2019-01-08  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/88331
        * function.c (assign_stack_local_1): Don't set dynamic_align_addr if
        not currently_expanding_to_rtl.

        * gcc.target/i386/pr88331.c: New test.

--- gcc/function.c.jj   2019-01-01 12:37:16.550984910 +0100
+++ gcc/function.c      2019-01-08 16:51:02.868722422 +0100
@@ -400,7 +400,9 @@ assign_stack_local_1 (machine_mode mode,
     {
       /* If the required alignment exceeds MAX_SUPPORTED_STACK_ALIGNMENT and
         it is not OK to reduce it.  Align the slot dynamically.  */
-      if (mode == BLKmode && (kind & ASLK_REDUCE_ALIGN) == 0)
+      if (mode == BLKmode
+         && (kind & ASLK_REDUCE_ALIGN) == 0
+         && currently_expanding_to_rtl)
        dynamic_align_addr = true;
       else
        {
--- gcc/testsuite/gcc.target/i386/pr88331.c.jj  2019-01-08 17:31:46.504540870 
+0100
+++ gcc/testsuite/gcc.target/i386/pr88331.c     2019-01-08 17:31:17.547014393 
+0100
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/88331 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=core-avx2" } */
+
+int b, d, e, g, i, j, l, m;
+int *c, *h, *n, *o;
+long f, k;
+
+void
+foo (void)
+{
+  long p = i;
+  int *a = o;
+  while (p)
+    {
+      n = (int *) (__UINTPTR_TYPE__) a[0];
+      for (; f; f += 4)
+       for (; m <= d;)
+         {
+           for (; g <= e; ++g)
+             l = (int) (__UINTPTR_TYPE__) (n + l);
+           c[m] = (int) (__UINTPTR_TYPE__) n;
+         }
+    }
+  int q = 0;
+  k = 0;
+  for (; k < j; k++)
+    q += o[k] * h[k];
+  b = q;
+}

        Jakub

Reply via email to