public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r10-10501] target/104453 - guard call folding with NULL LHS
Date: Wed, 16 Mar 2022 09:22:49 +0000 (GMT)	[thread overview]
Message-ID: <20220316092249.B305B3864C65@sourceware.org> (raw)

https://gcc.gnu.org/g:807bfd4357609655c81d0a3282b699b10e7aeb5a

commit r10-10501-g807bfd4357609655c81d0a3282b699b10e7aeb5a
Author: Richard Biener <rguenther@suse.de>
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  <rguenther@suse.de>
    
            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 cec0340ec51..19cb5d40c69 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17848,6 +17848,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);
+}


                 reply	other threads:[~2022-03-16  9:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220316092249.B305B3864C65@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).