]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: drop loop optimizations in fstack-protector-strong.c
authorAlexandre Oliva <oliva@adacore.com>
Tue, 31 Mar 2026 00:57:48 +0000 (21:57 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Tue, 31 Mar 2026 00:57:48 +0000 (21:57 -0300)
gcc.dg/fstack-protector-strong.c used to expect one stack_chk_fail per
function.  When vectorizer improvements caused foo2 to get vectorized
to the point of enabling the loop and the automatic array-containing
data structure to be optimized away entirely, it no longer required
stack protection, and the expected pattern count was decreased.

However, on platforms that don't or can't vectorize the loop, it isn't
optimized away, and then we find the wrong pattern count.

Reverse the decrease and disable optimizations of the loop that could
cause it to be optimized out, so that we get the originally-expected
stack protection everywhere.

for  gcc/testsuite/ChangeLog

* gcc.dg/fstack-protector-strong.c (foo2): Prevent loop
optimizations.  Expect stack protection again.

gcc/testsuite/gcc.dg/fstack-protector-strong.c

index b9f63966b7cccd4050c04253dab0418f45ad340b..52485b5252ddbddba4506ef491cdc92a52356925 100644 (file)
@@ -43,6 +43,8 @@ foo2 ()
 {
   struct AA aa;
   int i;
+#pragma GCC novector
+#pragma GCC unroll 0
   for (i = 0; i < 10; ++i)
     {
       aa.as.array[i] = i * (i-1) + i / 2;
@@ -154,4 +156,4 @@ void foo12 ()
   global3 ();
 }
 
-/* { dg-final { scan-assembler-times "stack_chk_fail" 11 } } */
+/* { dg-final { scan-assembler-times "stack_chk_fail" 12 } } */