From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 4330B3857806; Wed, 16 Mar 2022 09:55:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4330B3857806 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9985] target/104453 - guard call folding with NULL LHS X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: ba7394fce3e66201ec7166d22a5ef779d5e359d2 X-Git-Newrev: 48fde80dea1fd59db34d0723427c41d0fb1ad951 Message-Id: <20220316095537.4330B3857806@sourceware.org> Date: Wed, 16 Mar 2022 09:55:37 +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: Wed, 16 Mar 2022 09:55:37 -0000 https://gcc.gnu.org/g:48fde80dea1fd59db34d0723427c41d0fb1ad951 commit r9-9985-g48fde80dea1fd59db34d0723427c41d0fb1ad951 Author: Richard Biener Date: Wed Feb 9 08:48:35 2022 +0100 target/104453 - guard call folding with NULL LHS This guards shift builtin folding to do nothing when there is no LHS, similar to what other foldings do. 2022-02-09 Richard Biener PR target/104453 * config/i386/i386.c (ix86_gimple_fold_builtin): Guard shift folding for NULL LHS. * gcc.target/i386/pr104453.c: New testcase. (cherry picked from commit 1c827873ed283df282f2df11dfe0ff607e07dab3) Diff: --- gcc/config/i386/i386.c | 2 ++ gcc/testsuite/gcc.target/i386/pr104453.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b079985e9e2..8d00f6f94a0 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -33801,6 +33801,8 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi) do_shift: gcc_assert (n_args >= 2); + if (!gimple_call_lhs (stmt)) + break; arg0 = gimple_call_arg (stmt, 0); arg1 = gimple_call_arg (stmt, 1); if (n_args > 2) diff --git a/gcc/testsuite/gcc.target/i386/pr104453.c b/gcc/testsuite/gcc.target/i386/pr104453.c new file mode 100644 index 00000000000..325cedf0e2c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr104453.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f" } */ + +typedef short __attribute__((__vector_size__ (32))) V; +V g; + +void +foo (void) +{ + __builtin_ia32_psrawi256 (g, 0); +}