aarch64.c (aarch64_emit_probe_stack_range): Handle frame sizes that do not satisfy...
authorJeff Law <law@redhat.com>
Thu, 22 Jun 2017 17:18:05 +0000 (11:18 -0600)
committerJeff Law <law@gcc.gnu.org>
Thu, 22 Jun 2017 17:18:05 +0000 (11:18 -0600)
* config/aarch64/aarch64.c (aarch64_emit_probe_stack_range): Handle
frame sizes that do not satisfy aarch64_uimm12_shift.

* gcc.c-torture/compile/stack-check-1.c: New test.

From-SVN: r249566

gcc/ChangeLog
gcc/config/aarch64/aarch64.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/stack-check-1.c [new file with mode: 0644]

index 0a3426eef3ebf42e0666997407f02e41ffdf9dc9..03a824f6b3f3fd71055d9e97169afcad8a32dd9f 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-22  Jeff Law  <law@redhat.com>
+
+       * config/aarch64/aarch64.c (aarch64_emit_probe_stack_range): Handle
+       frame sizes that do not satisfy aarch64_uimm12_shift.
+
 2017-06-22  Jan Hubicka <hubicka@ucw.cz>
 
        * profile-count.h (apply_probability,
index 3364a02e89c7939e56770264ada7802fd62f3a13..95592f9fa17810d28327d0c99788bda8552b44bf 100644 (file)
@@ -2766,11 +2766,19 @@ aarch64_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size)
                     plus_constant (Pmode, stack_pointer_rtx, -first));
 
       /* LAST_ADDR = SP + FIRST + ROUNDED_SIZE.  */
-      emit_set_insn (reg2,
-                    plus_constant (Pmode, stack_pointer_rtx,
-                                   -(first + rounded_size)));
-
-
+      HOST_WIDE_INT adjustment = - (first + rounded_size);
+      if (! aarch64_uimm12_shift (adjustment))
+       {
+         aarch64_internal_mov_immediate (reg2, GEN_INT (adjustment),
+                                         true, Pmode);
+         emit_set_insn (reg2, gen_rtx_PLUS (Pmode, stack_pointer_rtx, reg2));
+       }
+      else
+       {
+         emit_set_insn (reg2,
+                        plus_constant (Pmode, stack_pointer_rtx, adjustment));
+       }
+               
       /* Step 3: the loop
 
         do
index 641e4124e377cec2d1341937263b41d2e8b28ab7..e162386fb683bdb04cca1ae42088181e7054d6a9 100644 (file)
@@ -1,3 +1,7 @@
+2017-06-22  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/compile/stack-check-1.c: New test.
+
 2016-06-22  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/vect/pr65947-1.c: Remove xfail.
diff --git a/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c b/gcc/testsuite/gcc.c-torture/compile/stack-check-1.c
new file mode 100644 (file)
index 0000000..4058eb5
--- /dev/null
@@ -0,0 +1,2 @@
+/* { dg-additional-options "-fstack-check" } */
+#include "20031023-1.c"