diff options
author | Hongyu Wang <hongyu.wang@intel.com> | 2024-05-09 10:12:16 +0800 |
---|---|---|
committer | Hongyu Wang <hongyu.wang@intel.com> | 2024-06-13 15:57:15 +0800 |
commit | 99e6cf404e37655be303e71f20df03c284c7989e (patch) | |
tree | 3ce5ce00139645bf6e784647e34994a37a68d054 /gcc | |
parent | 14820327c720dad2ca34eb9fa73c0d9b435b6688 (diff) | |
download | gcc-99e6cf404e37655be303e71f20df03c284c7989e.zip gcc-99e6cf404e37655be303e71f20df03c284c7989e.tar.gz gcc-99e6cf404e37655be303e71f20df03c284c7989e.tar.bz2 |
[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<mode>): Add new alternative
<r>,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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/i386/i386.md | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/apx-ccmp-1.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/apx-ccmp-2.c | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 5fc2bae..fd48e76 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" "<r>m,<r>") - (match_operand:SWI 3 "<general_operand>" "<r><i>,<r><m>")) + (minus:SWI (match_operand:SWI 2 "nonimmediate_operand" "<r>,<r>m,<r>") + (match_operand:SWI 3 "<general_operand>" "C,<r><i>,<m>")) (const_int 0)) - (unspec:SI + (unspec:CC [(match_operand:SI 4 "const_0_to_15_operand")] UNSPEC_APX_DFV)))] "TARGET_APX_CCMP" - "ccmp%C1{<imodesuffix>}\t%G4 {%3, %2|%2, %3}" + "@ + ctest%C1{<imodesuffix>}\t%G4 %2, %2 + ccmp%C1{<imodesuffix>}\t%G4 {%3, %2|%2, %3} + ccmp%C1{<imodesuffix>}\t%G4 {%3, %2|%2, %3}" [(set_attr "type" "icmp") (set_attr "mode" "<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 e4e112f..a8b7057 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 0123a68..4a07843 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; |