[PATCH v2] testsuite: Test both non-short-circuit settings for trapping comparisons

Torbjorn SVENSSON torbjorn.svensson@foss.st.com
Mon Oct 12 07:41:39 GMT 2026



On 2026-10-12 09:09, Andrea Pinski wrote:
> On Sun, Oct 11, 2026 at 11:54 PM Torbjörn SVENSSON
> <torbjorn.svensson@foss.st.com> wrote:
>>
>> Hi Andrea,
>>
>> Thanks for the quick review.
>> I hope I understood your correctly.
> 
> Yes you did. Ok.

Thanks.

Pushed as r17-5079-ga4a397c7d50224.

> 
>>
>> Tested below on arm-none-eabi top of r17-5048-gbd261b39dedc06.
>>
>> Ok for trunk?
>>
>> --
>>
>> fp-trapping-cmp-7.c was added in commit r17-4921-g8b90726a28bb63,
>> but has never passed on Cortex-M targets that disable non-short-circuit
>> operations.
>>
>> Split the test into two cases and set logical-op-non-short-circuit
>> explicitly.  One test checks that the comparisons are kept separate
>> when the parameter is 0, while the other checks that they are combined
>> when it is 1.  This makes the tests independent of target tuning and
>> covers both settings.
>>
>>          PR tree-optimization/53805
>>
>> gcc/testsuite/ChangeLog:
>>
>>          * gcc.dg/tree-ssa/fp-trapping-cmp-7.c: Pass --param
>>          logical-op-non-short-circuit=1.
>>          * gcc.dg/tree-ssa/fp-trapping-cmp-8.c: New test.
>>
>> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
>> ---
>>   gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-7.c |  2 +-
>>   gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-8.c | 14 ++++++++++++++
>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>   create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-8.c
>>
>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-7.c b/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-7.c
>> index 5916344877f..51a6f3bc761 100644
>> --- a/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-7.c
>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-7.c
>> @@ -1,5 +1,5 @@
>>   /* { dg-do compile } */
>> -/* { dg-options "-O1 -ftrapping-math -fdump-tree-ifcombine-details" } */
>> +/* { dg-options "-O1 -ftrapping-math -fdump-tree-ifcombine-details --param logical-op-non-short-circuit=1" } */
>>
>>   int
>>   f (double a, double b)
>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-8.c b/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-8.c
>> new file mode 100644
>> index 00000000000..613379db378
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/fp-trapping-cmp-8.c
>> @@ -0,0 +1,14 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O1 -ftrapping-math -fdump-tree-ifcombine-details --param logical-op-non-short-circuit=0" } */
>> +
>> +int
>> +f (double a, double b)
>> +{
>> +  if (a > b)
>> +    if (a == b)
>> +      return 1;
>> +  return 0;
>> +}
>> +
>> +/* { dg-final { scan-tree-dump-not "optimizing trapping cond to" "ifcombine" } } */
>> +/* { dg-final { scan-tree-dump-not "optimizing two comparisons to _\[0-9\]\+ & _\[0-9\]\+" "ifcombine" } } */
>> --
>> 2.43.0
>>



More information about the Gcc-patches mailing list