From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1251) id 22D29385842B; Wed, 28 Jun 2023 10:08:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22D29385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687946933; bh=tPaYaQBJPYWQI09gMN3gmXNzQXa5ysNo4FZV3f/yRyo=; h=From:To:Subject:Date:From; b=Q1Y1K8BY82oL6aQ1xD1v87KBV9JrZL4xYewmuqP2IpdPk0DQMDDqvjrLyglZmTGF3 Y4vkISd9q/axgD0xJlj6nTbRVk1Cjz4Gnmy6MyK/nmhsV8IF/hW2vx0WKEBd2tG0xM XP3T4oU4wo9KH9lkkeaaXJupCbY9ZJYrS/yqTdsw= 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 r14-2158] i386: Fix FAIL of gcc.target/i386/pr78794.c on ia32. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/heads/master X-Git-Oldrev: 45c53768b6fa3d737ae818e31d3c50da62e0ad2b X-Git-Newrev: c027592d39b2968005aa28bc84a946bab2668db8 Message-Id: <20230628100853.22D29385842B@sourceware.org> Date: Wed, 28 Jun 2023 10:08:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c027592d39b2968005aa28bc84a946bab2668db8 commit r14-2158-gc027592d39b2968005aa28bc84a946bab2668db8 Author: Roger Sayle Date: Wed Jun 28 11:07:47 2023 +0100 i386: Fix FAIL of gcc.target/i386/pr78794.c on ia32. This patch fixes that FAIL of gcc.target/i386/pr78794.c on ia32, which is caused by minor STV rtx_cost differences with -march=silvermont. It turns out that generic tuning results in pandn, but the lack of accurate parameterization for COMPARE in compute_convert_gain combined with small differences in scalar<->SSE costs on silvermont results in this DImode chain not being converted. The solution is to provide more accurate costs/gains for converting (DImode and SImode) comparisons. I'd been holding off of doing this as I'd thought it would be possible to turn pandn;ptestz into ptestc (for an even bigger scalar-to-vector win) but I've recently realized that these optimizations (as I've implemented them) occur in the wrong order (stv2 occurs after combine), so it isn't easy for STV to convert CCZmode into CCCmode. Doh! Perhaps something can be done in peephole2. 2023-06-28 Roger Sayle gcc/ChangeLog PR target/78794 * config/i386/i386-features.cc (compute_convert_gain): Provide more accurate gains for conversion of scalar comparisons to PTEST. Diff: --- gcc/config/i386/i386-features.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index 92ae08d442e..c676a90f51b 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -631,7 +631,31 @@ general_scalar_chain::compute_convert_gain () break; case COMPARE: - /* Assume comparison cost is the same. */ + if (XEXP (src, 1) != const0_rtx) + { + /* cmp vs. pxor;pshufd;ptest. */ + igain += COSTS_N_INSNS (m - 3); + } + else if (GET_CODE (XEXP (src, 0)) != AND) + { + /* test vs. pshufd;ptest. */ + igain += COSTS_N_INSNS (m - 2); + } + else if (GET_CODE (XEXP (XEXP (src, 0), 0)) != NOT) + { + /* and;test vs. pshufd;ptest. */ + igain += COSTS_N_INSNS (2 * m - 2); + } + else if (TARGET_BMI) + { + /* andn;test vs. pandn;pshufd;ptest. */ + igain += COSTS_N_INSNS (2 * m - 3); + } + else + { + /* not;and;test vs. pandn;pshufd;ptest. */ + igain += COSTS_N_INSNS (3 * m - 3); + } break; case CONST_INT: