https://gcc.gnu.org/g:7c510fdcf1d19998fb7cecc50677eb2ee477a7b1
commit r16-3391-g7c510fdcf1d19998fb7cecc50677eb2ee477a7b1 Author: Richard Earnshaw <rearn...@arm.com> Date: Tue Aug 26 11:55:29 2025 +0100 arm: testsuite: make gcc.target/arm/bics_3.c generate bics again 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. Diff: --- gcc/testsuite/gcc.target/arm/bics_3.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/arm/bics_3.c b/gcc/testsuite/gcc.target/arm/bics_3.c index 36b0b277d3fa..deea15faf959 100644 --- a/gcc/testsuite/gcc.target/arm/bics_3.c +++ b/gcc/testsuite/gcc.target/arm/bics_3.c @@ -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" } } */