From: Hongyu Wang Date: Thu, 9 May 2024 02:12:16 +0000 (+0800) Subject: [APX CCMP] Use ctestcc when comparing to const 0 X-Git-Tag: basepoints/gcc-16~8311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99e6cf404e37655be303e71f20df03c284c7989e;p=thirdparty%2Fgcc.git [APX CCMP] Use ctestcc when comparing to const 0 For CTEST, we don't have conditional AND so there's no optimization opportunity to write a new ctest pattern. Emit ctest when ccmp did comparison to const 0 to save bytes. gcc/ChangeLog: * config/i386/i386.md (@ccmp): Add new alternative ,C and adjust output templates. Also adjust UNSPEC mode to CCmode. gcc/testsuite/ChangeLog: * gcc.target/i386/apx-ccmp-1.c: Adjust output to scan ctest. * gcc.target/i386/apx-ccmp-2.c: Adjust some condition to compare with 0. --- diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 5fc2bae67f6..fd48e764469 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1515,14 +1515,17 @@ (match_operator 1 "comparison_operator" [(reg:CC FLAGS_REG) (const_int 0)]) (compare:CC - (minus:SWI (match_operand:SWI 2 "nonimmediate_operand" "m,") - (match_operand:SWI 3 "" ",")) + (minus:SWI (match_operand:SWI 2 "nonimmediate_operand" ",m,") + (match_operand:SWI 3 "" "C,,")) (const_int 0)) - (unspec:SI + (unspec:CC [(match_operand:SI 4 "const_0_to_15_operand")] UNSPEC_APX_DFV)))] "TARGET_APX_CCMP" - "ccmp%C1{}\t%G4 {%3, %2|%2, %3}" + "@ + ctest%C1{}\t%G4 %2, %2 + ccmp%C1{}\t%G4 {%3, %2|%2, %3} + ccmp%C1{}\t%G4 {%3, %2|%2, %3}" [(set_attr "type" "icmp") (set_attr "mode" "") (set_attr "length_immediate" "1") diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c index e4e112f07e0..a8b70576760 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c @@ -96,9 +96,11 @@ f15 (double a, double b, int c, int d) /* { dg-final { scan-assembler-times "ccmpg" 2 } } */ /* { dg-final { scan-assembler-times "ccmple" 2 } } */ -/* { dg-final { scan-assembler-times "ccmpne" 4 } } */ -/* { dg-final { scan-assembler-times "ccmpe" 3 } } */ +/* { dg-final { scan-assembler-times "ccmpne" 2 } } */ +/* { dg-final { scan-assembler-times "ccmpe" 1 } } */ /* { dg-final { scan-assembler-times "ccmpbe" 1 } } */ +/* { dg-final { scan-assembler-times "ctestne" 2 } } */ +/* { dg-final { scan-assembler-times "cteste" 2 } } */ /* { dg-final { scan-assembler-times "ccmpa" 1 } } */ -/* { dg-final { scan-assembler-times "ccmpbl" 2 } } */ - +/* { dg-final { scan-assembler-times "ccmpbl" 1 } } */ +/* { dg-final { scan-assembler-times "ctestbl" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c index 0123a686d2c..4a0784394c3 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c @@ -12,7 +12,7 @@ int foo_apx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b; @@ -32,7 +32,7 @@ int foo_noapx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b;