]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: testsuite: tweak bics_3.c [PR113542]
authorRichard Earnshaw <rearnsha@arm.com>
Fri, 8 Mar 2024 16:23:53 +0000 (16:23 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Fri, 8 Mar 2024 17:06:18 +0000 (17:06 +0000)
This test was too simple, which meant that the compiler was sometimes
able to find a better optimization of the code than using a BICS
instruction.  Fix this by changing the test slightly to produce a
sequence where BICS should always be the preferred solution.

gcc/testsuite:
PR target/113542
* gcc.target/arm/bics_3.c: Adjust code to something which should
always result in BICS.

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

index e056b264e15fa847ba77e625083db66b3f174c93..4d6938948a139aaa92295d8e45b37d721c7c0b07 100644 (file)
@@ -2,13 +2,11 @@
 /* { dg-options "-O2 --save-temps -fno-inline" } */
 /* { dg-require-effective-target arm32 } */
 
-extern void abort (void);
-
 int
 bics_si_test (int a, int b)
 {
-  if (a & ~b)
-    return 1;
+  if ((a & ~b) >= 0)
+    return 3;
   else
     return 0;
 }
@@ -16,8 +14,8 @@ bics_si_test (int a, int b)
 int
 bics_si_test2 (int a, int b)
 {
-  if (a & ~ (b << 2))
-    return 1;
+  if ((a & ~ (b << 2)) >= 0)
+    return 3;
   else
     return 0;
 }
@@ -28,13 +26,12 @@ main (void)
   int a = 5;
   int b = 5;
   int c = 20;
-  if (bics_si_test (a, b))
-    abort ();
-  if (bics_si_test2 (c, b))
-    abort ();
+  if (bics_si_test (a, b) != 3)
+    __builtin_abort ();
+  if (bics_si_test2 (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 } } */
-