From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2078) id 2DC57385840A; Sun, 23 Apr 2023 01:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DC57385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682215042; bh=DriGI7Jnwvw9baXQchkIstqaO10Z2GZarczjdMWG6/E=; h=From:To:Subject:Date:From; b=LLUOfyK6xgDMR+mW3Wwpzujn++7AYEW7WRKAqoOuq8T1aIf4I6tLE3ka65KekDv5e HzNVDo5RSVSoqCO1Mw2A2fQD5CumMZiKjJzbwfkFTIhDxDDHwybLm8YGuAHLx8tive 6FogwOvuZJGHisszYuLEcoA0ATWM+v5f9UCq0g44= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: hongtao Liu To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-172] Use NO_REGS in cost calculation when the preferred register class are not known yet. X-Act-Checkin: gcc X-Git-Author: liuhongt X-Git-Refname: refs/heads/master X-Git-Oldrev: 6ab856aa49bef7c04efa6144a5048e129b3a058b X-Git-Newrev: 0368d169492017cfab5622d38b15be94154d458c Message-Id: <20230423015722.2DC57385840A@sourceware.org> Date: Sun, 23 Apr 2023 01:57:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0368d169492017cfab5622d38b15be94154d458c commit r14-172-g0368d169492017cfab5622d38b15be94154d458c Author: liuhongt Date: Wed Feb 8 12:42:27 2023 +0800 Use NO_REGS in cost calculation when the preferred register class are not known yet. gcc/ChangeLog: PR rtl-optimization/108707 * ira-costs.cc (scan_one_insn): Use NO_REGS instead of GENERAL_REGS when preferred reg_class is not known. gcc/testsuite/ChangeLog: * gcc.target/i386/pr108707.c: New test. Diff: --- gcc/ira-costs.cc | 5 ++++- gcc/testsuite/gcc.target/i386/pr108707.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc index c0fdef807dd..d2a801ab9b0 100644 --- a/gcc/ira-costs.cc +++ b/gcc/ira-costs.cc @@ -1572,7 +1572,10 @@ scan_one_insn (rtx_insn *insn) && (! ira_use_lra_p || ! pic_offset_table_rtx || ! contains_symbol_ref_p (XEXP (note, 0)))) { - enum reg_class cl = GENERAL_REGS; + /* Costs for NO_REGS are used in cost calculation on the + 1st pass when the preferred register classes are not + known yet. In this case we take the best scenario. */ + enum reg_class cl = NO_REGS; rtx reg = SET_DEST (set); int num = COST_INDEX (REGNO (reg)); diff --git a/gcc/testsuite/gcc.target/i386/pr108707.c b/gcc/testsuite/gcc.target/i386/pr108707.c new file mode 100644 index 00000000000..6405cfe7cdc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr108707.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-not {(?n)vfmadd[1-3]*ps.*\(} { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times {(?n)vfmadd[1-3]*ps[ \t]*} 3 } } */ + +#include + +void +foo (__m512 pv, __m512 a, __m512 b, __m512 c, + __m512* pdest, __m512* p1) +{ + __m512 t = *p1; + pdest[0] = _mm512_fmadd_ps (t, pv, a); + pdest[1] = _mm512_fmadd_ps (t, pv, b); + pdest[2] = _mm512_fmadd_ps (t, pv, c); +}