From 6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Mon, 15 Aug 2022 17:43:02 +0100 Subject: [PATCH] Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64. 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 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index effc2f24494..28914de0ac2 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -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; } -- 2.47.2