[gcc r15-1242] [APX CCMP] Use ctestcc when comparing to const 0
Hongyu Wang
hongyuw@gcc.gnu.org
Thu Jun 13 07:59:49 GMT 2024
https://gcc.gnu.org/g:99e6cf404e37655be303e71f20df03c284c7989e
commit r15-1242-g99e6cf404e37655be303e71f20df03c284c7989e
Author: Hongyu Wang <hongyu.wang@intel.com>
Date: Thu May 9 10:12:16 2024 +0800
[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.
Diff:
---
gcc/config/i386/i386.md | 11 +++++++----
gcc/testsuite/gcc.target/i386/apx-ccmp-1.c | 10 ++++++----
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 5fc2bae67f6b..fd48e7644695 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 e4e112f07e05..a8b705767600 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 0123a686d2c4..4a0784394c32 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;
More information about the Gcc-cvs
mailing list