]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: testsuite: make gcc.target/arm/bics_3.c generate bics again
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 26 Aug 2025 10:55:29 +0000 (11:55 +0100)
committerRichard Earnshaw <rearnsha@arm.com>
Tue, 26 Aug 2025 12:03:15 +0000 (13:03 +0100)
The compiler is getting too smart!  But this test is really intended
to test that we generate BICS instead of BIC+CMP, so make the test use
something that we can't subsequently fold away into a bit minipulation
of a store-flag value.

I've also added a couple of extra tests, so we now cover both the
cases where we fold the result away and where that cannot be done.
Also add a test that we don't generate a compare against 0, since
that's really part of what this test is covering.

gcc/testsuite:

* gcc.target/arm/bics_3.c: Add some additional tests that
cannot be folded to a bit manipulation.

gcc/testsuite/gcc.target/arm/bics_3.c

index 36b0b277d3fa124644a92b680811348241d2bb77..deea15faf959fd2e2ba99f4669d021d73fc43869 100644 (file)
@@ -2,17 +2,39 @@
 /* { dg-options "-O2 --save-temps -fno-inline" } */
 /* { dg-require-effective-target arm32 } */
 
+volatile int three = 3;
+
+/* The following need a BICS, rather than BIC+CMP.  */
 int
 bics_si_test (int a, int b)
 {
   if ((a & ~b) >= 0)
-    return 3;
+    return three;
   else
     return 0;
 }
 
 int
 bics_si_test2 (int a, int b)
+{
+  if ((a & ~ (b << 2)) >= 0)
+    return three;
+  else
+    return 0;
+}
+
+/* The following no-longer need a BICS and conditional execution.  */
+int
+bics_si_test3 (int a, int b)
+{
+  if ((a & ~b) >= 0)
+    return 3;
+  else
+    return 0;
+}
+
+int
+bics_si_test4 (int a, int b)
 {
   if ((a & ~ (b << 2)) >= 0)
     return 3;
@@ -30,8 +52,15 @@ main (void)
     __builtin_abort ();
   if (bics_si_test2 (c, b) != 3)
     __builtin_abort ();
+  if (bics_si_test3 (a, b) != 3)
+    __builtin_abort ();
+  if (bics_si_test4 (c, b) != 3)
+    __builtin_abort ();
   return 0;
 }
 
+/* { dg-final { scan-assembler-times "bics\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 2 } } */
+/* { dg-final { scan-assembler-times "bics\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+, .sl #2" 1 } } */
 /* { dg-final { scan-assembler-times "bic\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+" 2 } } */
 /* { dg-final { scan-assembler-times "bic\tr\[0-9\]+, r\[0-9\]+, r\[0-9\]+, .sl #2" 1 } } */
+/* { dg-final { scan-assembler-not "cmp\tr\[0-9]+, #0" } } */