public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-6485] i386: Fix ICE on __builtin_ia32_pabsd128 without lhs [PR112962]
@ 2023-12-13 10:34 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-12-13 10:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:02c30fdad2f46a1f7b4e30d0eff0ac275cd108a5

commit r14-6485-g02c30fdad2f46a1f7b4e30d0eff0ac275cd108a5
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 13 11:34:12 2023 +0100

    i386: Fix ICE on __builtin_ia32_pabsd128 without lhs [PR112962]
    
    The following patch fixes ICE on the testcase in similar way to how
    other folded builtins are handled in ix86_gimple_fold_builtin when
    they don't have a lhs; these builtins are const or pure, so normally
    DCE would remove them later, but with -O0 that isn't guaranteed to
    happen, and during expansion if they are marked TREE_SIDE_EFFECTS
    it might still be attempted to be expanded.
    This removes them right away during the folding.
    
    Initially I wanted to also change all gsi_replace last args in that function
    to true, but Andrew pointed to PR107209, so I've kept them as is.
    
    2023-12-13  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/112962
            * config/i386/i386.cc (ix86_gimple_fold_builtin): For shifts
            and abs without lhs replace with nop.
    
            * gcc.target/i386/pr112962.c: New test.

Diff:
---
 gcc/config/i386/i386.cc                  | 10 ++++++++--
 gcc/testsuite/gcc.target/i386/pr112962.c | 11 +++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 4706f0d4059..3e78949c7a6 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -19377,7 +19377,10 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
     do_shift:
       gcc_assert (n_args >= 2);
       if (!gimple_call_lhs (stmt))
-	break;
+	{
+	  gsi_replace (gsi, gimple_build_nop (), false);
+	  return true;
+	}
       arg0 = gimple_call_arg (stmt, 0);
       arg1 = gimple_call_arg (stmt, 1);
       elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
@@ -19523,7 +19526,10 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
     case IX86_BUILTIN_PABSD256_MASK:
       gcc_assert (n_args >= 1);
       if (!gimple_call_lhs (stmt))
-	break;
+	{
+	  gsi_replace (gsi, gimple_build_nop (), false);
+	  return true;
+	}
       arg0 = gimple_call_arg (stmt, 0);
       elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
       /* For masked ABS, only optimize if the mask is all ones.  */
diff --git a/gcc/testsuite/gcc.target/i386/pr112962.c b/gcc/testsuite/gcc.target/i386/pr112962.c
new file mode 100644
index 00000000000..8dfc0a6beaf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112962.c
@@ -0,0 +1,11 @@
+/* PR target/112962 */
+/* { dg-do compile } */
+/* { dg-options "-fexceptions -mssse3" } */
+
+typedef int __attribute__((__vector_size__ (16))) V;
+
+void
+foo (void)
+{
+  __builtin_ia32_pabsd128 ((V) {});
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-13 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 10:34 [gcc r14-6485] i386: Fix ICE on __builtin_ia32_pabsd128 without lhs [PR112962] Jakub Jelinek

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).