aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkonglin1 <lingling.kong@intel.com>2024-05-08 15:46:10 +0800
committerkonglin1 <lingling.kong@intel.com>2024-05-08 15:46:22 +0800
commitd826f7945609046f922732b138fb90795d5b1985 (patch)
treea62e0494fd36548df63e5bb52954fa147ffa855f
parent36e877996936abd8bd08f8b1d983c8d1023a5842 (diff)
downloadgcc-d826f7945609046f922732b138fb90795d5b1985.zip
gcc-d826f7945609046f922732b138fb90795d5b1985.tar.gz
gcc-d826f7945609046f922732b138fb90795d5b1985.tar.bz2
x86: Fix cmov cost model issue [PR109549]
(if_then_else:SI (eq (reg:CCZ 17 flags) (const_int 0 [0])) (reg/v:SI 101 [ e ]) (reg:SI 102)) The cost is 8 for the rtx, the cost for (eq (reg:CCZ 17 flags) (const_int 0 [0])) is 4, but this is just an operator do not need to compute it's cost in cmov. gcc/ChangeLog: PR target/109549 * config/i386/i386.cc (ix86_rtx_costs): The XEXP (x, 0) for cmov is an operator do not need to compute cost. gcc/testsuite/ChangeLog: * gcc.target/i386/cmov6.c: Fixed.
-rw-r--r--gcc/config/i386/i386.cc2
-rw-r--r--gcc/testsuite/gcc.target/i386/cmov6.c5
2 files changed, 2 insertions, 5 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index e58335a..c2df4ab 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -22237,7 +22237,7 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno,
{
/* cmov. */
*total = COSTS_N_INSNS (1);
- if (!REG_P (XEXP (x, 0)))
+ if (!COMPARISON_P (XEXP (x, 0)) && !REG_P (XEXP (x, 0)))
*total += rtx_cost (XEXP (x, 0), mode, code, 0, speed);
if (!REG_P (XEXP (x, 1)))
*total += rtx_cost (XEXP (x, 1), mode, code, 1, speed);
diff --git a/gcc/testsuite/gcc.target/i386/cmov6.c b/gcc/testsuite/gcc.target/i386/cmov6.c
index 5111c8a..535326e 100644
--- a/gcc/testsuite/gcc.target/i386/cmov6.c
+++ b/gcc/testsuite/gcc.target/i386/cmov6.c
@@ -1,9 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=k8" } */
-/* if-converting this sequence would require two cmov
- instructions and seems to always cost more independent
- of the TUNE_ONE_IF_CONV setting. */
-/* { dg-final { scan-assembler-not "cmov\[^6\]" } } */
+/* { dg-final { scan-assembler "cmov\[^6\]" } } */
/* Verify that blocks are converted to conditional moves. */
extern int bar (int, int);