From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1251) id 3632C3858429; Mon, 15 Aug 2022 16:44:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3632C3858429 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Roger Sayle To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2049] Improved gain calculation for COMPARE to 0 or -1 in TImode STV on x86_64. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/heads/master X-Git-Oldrev: 418b71c0d535bf91df78bad2e198c57934682eaa X-Git-Newrev: 6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c Message-Id: <20220815164403.3632C3858429@sourceware.org> Date: Mon, 15 Aug 2022 16:44:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Aug 2022 16:44:03 -0000 https://gcc.gnu.org/g:6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c commit r13-2049-g6f94923dea21bd92ba2fc40c4a3be509bb1b7f0c Author: Roger Sayle Date: Mon Aug 15 17:43:02 2022 +0100 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. Diff: --- 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; }