]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
target/104453 - guard call folding with NULL LHS
authorRichard Biener <rguenther@suse.de>
Wed, 9 Feb 2022 07:48:35 +0000 (08:48 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 16 Mar 2022 08:29:51 +0000 (09:29 +0100)
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)

gcc/config/i386/i386.c
gcc/testsuite/gcc.target/i386/pr104453.c [new file with mode: 0644]

index cec0340ec51fab09b0ae287b4a1146502d0d7043..19cb5d40c694d84edc9286dbffa6178927ea0434 100644 (file)
@@ -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 (file)
index 0000000..325cedf
--- /dev/null
@@ -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);
+}