]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64.
authorRoger Sayle <roger@nextmovesoftware.com>
Mon, 15 Aug 2022 16:43:02 +0000 (17:43 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Mon, 15 Aug 2022 16:43:02 +0000 (17:43 +0100)
This patch tweaks timode_scalar_chain::compute_convert_gain to provide
more accurate costs for converting TImode comparisons against zero or
minus 1 to V1TImode equivalents.

2022-08-15  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-features.cc
(timode_scalar_chain::compute_convert_gain): Provide gains for
comparisons against 0/-1, including "*testti" patterns.

gcc/config/i386/i386-features.cc

index effc2f24494766331ab9978eb15e707d1a9d4d90..28914de0ac26e385dfab7cb7d82811b0646e440d 100644 (file)
@@ -1250,6 +1250,23 @@ timode_scalar_chain::compute_convert_gain ()
                                              : COSTS_N_INSNS (1);
          break;
 
+       case COMPARE:
+         if (XEXP (src, 1) == const0_rtx)
+           {
+             if (GET_CODE (XEXP (src, 0)) == AND)
+               /* and;and;or (9 bytes) vs. ptest (5 bytes).  */
+               igain = optimize_insn_for_size_p() ? COSTS_N_BYTES (4)
+                                                  : COSTS_N_INSNS (2);
+             /* or (3 bytes) vs. ptest (5 bytes).  */
+             else if (optimize_insn_for_size_p ())
+               igain = -COSTS_N_BYTES (2);
+           }
+         else if (XEXP (src, 1) == const1_rtx)
+           /* and;cmp -1 (7 bytes) vs. pcmpeqd;pxor;ptest (13 bytes).  */
+           igain = optimize_insn_for_size_p() ? -COSTS_N_BYTES (6)
+                                              : -COSTS_N_INSNS (1);
+         break;
+
        default:
          break;
        }