]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[APX CCMP] Use ctestcc when comparing to const 0
authorHongyu Wang <hongyu.wang@intel.com>
Thu, 9 May 2024 02:12:16 +0000 (10:12 +0800)
committerHongyu Wang <hongyu.wang@intel.com>
Thu, 13 Jun 2024 07:57:15 +0000 (15:57 +0800)
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.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/apx-ccmp-1.c
gcc/testsuite/gcc.target/i386/apx-ccmp-2.c

index 5fc2bae67f6bce4d003822e6dba9c3223c11a489..fd48e76446951614dcaaaa3b97d7b43072352870 100644 (file)
         (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")
index e4e112f07e052e3f20602df6ae7f91d7aa80ac2d..a8b7057676002f40eb93bf88a5e9bc5fa4bb0422 100644 (file)
@@ -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 } } */
index 0123a686d2c4117ffc296d798abb26264f30853d..4a0784394c32660ed853489c5cac6db71b8f9d02 100644 (file)
@@ -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;