diff mbox series

[COMMITTED] arm: testsuite: tweak bics_3.c [PR113542]

Message ID 20240308170838.2680359-1-rearnsha@arm.com
State New
Headers show
Series [COMMITTED] arm: testsuite: tweak bics_3.c [PR113542] | expand

Commit Message

Richard Earnshaw March 8, 2024, 5:08 p.m. UTC
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 | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/arm/bics_3.c b/gcc/testsuite/gcc.target/arm/bics_3.c
index e056b264e15..4d6938948a1 100644
--- a/gcc/testsuite/gcc.target/arm/bics_3.c
+++ b/gcc/testsuite/gcc.target/arm/bics_3.c
@@ -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 } } */
-