public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
@ 2023-12-11 14:59 zsojka at seznam dot cz
  2023-12-12  7:21 ` [Bug target/112962] " rguenth at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: zsojka at seznam dot cz @ 2023-12-11 14:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

            Bug ID: 112962
           Summary: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*,
                    rtx_def*> (recog.h:431) with -fexceptions -mssse3 and
                    __builtin_ia32_pabsd128()
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 56850
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56850&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -fexceptions -mssse3 testcase.c -wrapper valgrind,-q
==15604== Jump to the invalid address stated on the next line
==15604==    at 0x0: ???
==15604==    by 0x19A93F0: operator()<rtx_def*, rtx_def*> (recog.h:431)
==15604==    by 0x19A93F0: ix86_expand_args_builtin(builtin_description const*,
tree_node*, rtx_def*) (i386-expand.cc:11848)
==15604==    by 0x10B1BCF: expand_expr_real_1(tree_node*, rtx_def*,
machine_mode, expand_modifier, rtx_def**, bool) (expr.cc:12305)
==15604==    by 0xF73D28: expand_expr (expr.h:313)
==15604==    by 0xF73D28: expand_call_stmt (cfgexpand.cc:2832)
==15604==    by 0xF73D28: expand_gimple_stmt_1 (cfgexpand.cc:3894)
==15604==    by 0xF73D28: expand_gimple_stmt(gimple*) (cfgexpand.cc:4058)
==15604==    by 0xF7A0AE: expand_gimple_basic_block(basic_block_def*, bool)
(cfgexpand.cc:6114)
==15604==    by 0xF7BD87: (anonymous
namespace)::pass_expand::execute(function*) (cfgexpand.cc:6849)
==15604==    by 0x13B774A: execute_one_pass(opt_pass*) (passes.cc:2646)
==15604==    by 0x13B803F: execute_pass_list_1(opt_pass*) (passes.cc:2755)
==15604==    by 0x13B8078: execute_pass_list(function*, opt_pass*)
(passes.cc:2766)
==15604==    by 0xFBCA35: expand (cgraphunit.cc:1842)
==15604==    by 0xFBCA35: cgraph_node::expand() (cgraphunit.cc:1795)
==15604==    by 0xFBD949: output_in_order (cgraphunit.cc:2192)
==15604==    by 0xFBD949: symbol_table::compile() [clone .part.0]
(cgraphunit.cc:2396)
==15604==    by 0xFC08F7: compile (cgraphunit.cc:2312)
==15604==    by 0xFC08F7: symbol_table::finalize_compilation_unit()
(cgraphunit.cc:2584)
==15604==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==15604==
during RTL pass: expand
testcase.c: In function 'foo':
testcase.c:6:3: internal compiler error: Segmentation fault
    6 |   __builtin_ia32_pabsd128 ((V){});
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x14f8def crash_signal
        /repo/gcc-trunk/gcc/toplev.cc:316
0x0 subreg_lowpart_offset(machine_mode, machine_mode)
        /repo/gcc-trunk/gcc/machmode.h:566
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-6412-20231211150807-g2505a8b41d3-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-6412-20231211150807-g2505a8b41d3-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20231211 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
@ 2023-12-12  7:21 ` rguenth at gcc dot gnu.org
  2023-12-12  9:05 ` ubizjak at gmail dot com
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-12  7:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
  2023-12-12  7:21 ` [Bug target/112962] " rguenth at gcc dot gnu.org
@ 2023-12-12  9:05 ` ubizjak at gmail dot com
  2023-12-12  9:36 ` jakub at gcc dot gnu.org
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ubizjak at gmail dot com @ 2023-12-12  9:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ubizjak at gmail dot com
   Last reconfirmed|                            |2023-12-12
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 56862
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56862&action=edit
Proposed patch

Patch in testing.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
  2023-12-12  7:21 ` [Bug target/112962] " rguenth at gcc dot gnu.org
  2023-12-12  9:05 ` ubizjak at gmail dot com
@ 2023-12-12  9:36 ` jakub at gcc dot gnu.org
  2023-12-12  9:38 ` jakub at gcc dot gnu.org
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12  9:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-1145-g1ede03e2d0437ea9c2f7453fcbe263505b4e0def

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-12-12  9:36 ` jakub at gcc dot gnu.org
@ 2023-12-12  9:38 ` jakub at gcc dot gnu.org
  2023-12-12  9:38 ` ubizjak at gmail dot com
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12  9:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I was thinking whether it wouldn't be better to expand x86 const or pure
builtins when lhs is ignored to nothing in the expanders.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2023-12-12  9:38 ` jakub at gcc dot gnu.org
@ 2023-12-12  9:38 ` ubizjak at gmail dot com
  2023-12-12  9:39 ` jakub at gcc dot gnu.org
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ubizjak at gmail dot com @ 2023-12-12  9:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #3)
> I was thinking whether it wouldn't be better to expand x86 const or pure
> builtins when lhs is ignored to nothing in the expanders.

Yes, this could be a better solution.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2023-12-12  9:38 ` ubizjak at gmail dot com
@ 2023-12-12  9:39 ` jakub at gcc dot gnu.org
  2023-12-12  9:54 ` ubizjak at gmail dot com
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12  9:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With -O1 or higher there is some DCE which will remove them (unless disabled),
but the above ICE is with -O0...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2023-12-12  9:39 ` jakub at gcc dot gnu.org
@ 2023-12-12  9:54 ` ubizjak at gmail dot com
  2023-12-12 10:03 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ubizjak at gmail dot com @ 2023-12-12  9:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #3)
> I was thinking whether it wouldn't be better to expand x86 const or pure
> builtins when lhs is ignored to nothing in the expanders.

Something like this?

--cut here--
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index a53d69d5400..0f3d6108d77 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -13032,6 +13032,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx
subtarget,
   unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
   HOST_WIDE_INT bisa, bisa2;

+  if (ignore && (TREE_READONLY (fndecl) || DECL_PURE_P (fndecl)))
+    return const0_rtx;
+
   /* For CPU builtins that can be folded, fold first and expand the fold.  */
   switch (fcode)
     {
@@ -14401,9 +14404,6 @@ rdseed_step:
       return target;

     case IX86_BUILTIN_READ_FLAGS:
-      if (ignore)
-       return const0_rtx;
-
       emit_insn (gen_pushfl ());

       if (optimize
--cut here--

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2023-12-12  9:54 ` ubizjak at gmail dot com
@ 2023-12-12 10:03 ` jakub at gcc dot gnu.org
  2023-12-12 10:08 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12 10:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
On the other side, maybe we want some of the diagnostics that is only done at
expansion time (argument xyz must be such and such immediate).  Though, at -O2
it isn't diagnosed anyway because it is DCEd.
Anyway, with just -O0 -mssse3 this works fine because of expr.cc:
11097     /* If we are going to ignore this result, we need only do something
11098        if there is a side-effect somewhere in the expression.  If there
11099        is, short-circuit the most common cases here.  Note that we must
11100        not call expand_expr with anything but const0_rtx in case this
11101        is an initial expansion of a size that contains a
PLACEHOLDER_EXPR.  */
11102   
11103     if (ignore)
11104       {
11105         if (! TREE_SIDE_EFFECTS (exp))
11106           return const0_rtx;
but with -fexceptions (and probably because we incorrectly don't mark the
builtins nothrow?) this doesn't happen.
I was thinking about something like
--- gcc/i386-expand.cc.jj       2023-12-07 08:31:59.855850982 +0100
+++ gcc/i386-expand.cc  2023-12-12 11:02:54.524733315 +0100
@@ -11842,6 +11842,12 @@ ix86_expand_args_builtin (const struct b
       xops[i] = op;
     }

+  if (icode == CODE_FOR_nothing)
+    {
+      gcc_assert (target == const0_rtx);
+      return const0_rtx;
+    }
+
   switch (nargs)
     {
     case 1:
but of course, your choice...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2023-12-12 10:03 ` jakub at gcc dot gnu.org
@ 2023-12-12 10:08 ` jakub at gcc dot gnu.org
  2023-12-12 10:12 ` ubizjak at gmail dot com
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12 10:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Of course, yet another option is:
--- gcc/config/i386/i386.cc     2023-12-12 08:54:39.821148670 +0100
+++ gcc/config/i386/i386.cc     2023-12-12 11:07:03.795286363 +0100
@@ -19377,7 +19377,10 @@ ix86_gimple_fold_builtin (gimple_stmt_it
     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_it
     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.  */
(and I wonder why all the gsi_replace calls in that function are with false,
IMHO they should use true).

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (8 preceding siblings ...)
  2023-12-12 10:08 ` jakub at gcc dot gnu.org
@ 2023-12-12 10:12 ` ubizjak at gmail dot com
  2023-12-12 10:15 ` ubizjak at gmail dot com
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ubizjak at gmail dot com @ 2023-12-12 10:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #8)
> Of course, yet another option is:

This goes out of my (limited) area of expertise, so if my proposed (trivial)
patch is papering over some other issue, I'll happily leave the solution to
you.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (9 preceding siblings ...)
  2023-12-12 10:12 ` ubizjak at gmail dot com
@ 2023-12-12 10:15 ` ubizjak at gmail dot com
  2023-12-12 10:36 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: ubizjak at gmail dot com @ 2023-12-12 10:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|ubizjak at gmail dot com           |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #10 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #7)

> but with -fexceptions (and probably because we incorrectly don't mark the
> builtins nothrow?) this doesn't happen.

Maybe we should finally fix the above nothrow issue?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (10 preceding siblings ...)
  2023-12-12 10:15 ` ubizjak at gmail dot com
@ 2023-12-12 10:36 ` jakub at gcc dot gnu.org
  2023-12-12 11:06 ` liuhongt at gcc dot gnu.org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12 10:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Sure.  But we need to find out first what builtins might actually throw.
Perhaps with -fnon-call-exceptions those which read/store (vector loads/stores,
masked loads/stores, scatters/gathers?) memory can?  Unsure if we handle it
though...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (11 preceding siblings ...)
  2023-12-12 10:36 ` jakub at gcc dot gnu.org
@ 2023-12-12 11:06 ` liuhongt at gcc dot gnu.org
  2023-12-12 11:08 ` liuhongt at gcc dot gnu.org
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-12-12 11:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #12 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> Of course, yet another option is:
> --- gcc/config/i386/i386.cc	2023-12-12 08:54:39.821148670 +0100
> +++ gcc/config/i386/i386.cc	2023-12-12 11:07:03.795286363 +0100
> @@ -19377,7 +19377,10 @@ ix86_gimple_fold_builtin (gimple_stmt_it
>      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_it
>      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.  */
> (and I wonder why all the gsi_replace calls in that function are with false,
> IMHO they should use true).

I prefer this solution, that's what we did for blendvps case.
I don't know either, just follow what we did before (with false) when folding
builtins.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (12 preceding siblings ...)
  2023-12-12 11:06 ` liuhongt at gcc dot gnu.org
@ 2023-12-12 11:08 ` liuhongt at gcc dot gnu.org
  2023-12-12 11:24 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-12-12 11:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #13 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---

> I prefer this solution, that's what we did for blendvps case.
> I don't know either, just follow what we did before (with false) when
> folding builtins.
I mean when I was working on
r14-1145-g1ede03e2d0437ea9c2f7453fcbe263505b4e0def, I'm just follow the existed
code.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (13 preceding siblings ...)
  2023-12-12 11:08 ` liuhongt at gcc dot gnu.org
@ 2023-12-12 11:24 ` jakub at gcc dot gnu.org
  2023-12-12 11:26 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12 11:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 56863
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56863&action=edit
gcc14-pr112962-1.patch

Patch I'm going to test.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (14 preceding siblings ...)
  2023-12-12 11:24 ` jakub at gcc dot gnu.org
@ 2023-12-12 11:26 ` jakub at gcc dot gnu.org
  2023-12-12 22:59 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-12 11:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 56864
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56864&action=edit
gcc14-pr112962-2.patch

And another one for nothrow/leaf.  I'm too lazy to figure out the exact details
for -fnon-call-exceptions, will defer that to somebody who cares about those
and has time to figure out all the details.
I think e.g. aarch64 doesn't set nothrow on builtins with -fnon-call-exceptions
if they might raise floating point exceptions or read/write memory.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (15 preceding siblings ...)
  2023-12-12 11:26 ` jakub at gcc dot gnu.org
@ 2023-12-12 22:59 ` pinskia at gcc dot gnu.org
  2023-12-13 10:34 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-12 22:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #15)
> I think e.g. aarch64 doesn't set nothrow on builtins with
> -fnon-call-exceptions if they might raise floating point exceptions or
> read/write memory.

That is correct, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107209#c7 for
a change related to aarch64's builtins and non-call exceptions and folding
there.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (16 preceding siblings ...)
  2023-12-12 22:59 ` pinskia at gcc dot gnu.org
@ 2023-12-13 10:34 ` cvs-commit at gcc dot gnu.org
  2023-12-13 11:10 ` jakub at gcc dot gnu.org
  2023-12-20 11:02 ` cvs-commit at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-13 10:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #17 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (17 preceding siblings ...)
  2023-12-13 10:34 ` cvs-commit at gcc dot gnu.org
@ 2023-12-13 11:10 ` jakub at gcc dot gnu.org
  2023-12-20 11:02 ` cvs-commit at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-13 11:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Bug target/112962] [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128()
  2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
                   ` (18 preceding siblings ...)
  2023-12-13 11:10 ` jakub at gcc dot gnu.org
@ 2023-12-20 11:02 ` cvs-commit at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-20 11:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112962

--- Comment #19 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:96e0b513717e25405aee36851d5164aab0d0403a

commit r14-6743-g96e0b513717e25405aee36851d5164aab0d0403a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 20 12:01:57 2023 +0100

    i386: Make most MD builtins nothrow, leaf [PR112962]

    The following patch makes most of x86 MD builtins nothrow,leaf
    (like most middle-end builtins are).  For -fnon-call-exceptions it
    doesn't nothrow, better might be to still add it if the builtins
    don't read or write memory and can't raise floating point exceptions,
    but we don't have such information readily available, so the patch
    uses just !flag_non_call_exceptions for now.
    Not sure if we shouldn't have some exceptions for the leaf attribute,
    e.g. wonder about EMMS/FEMMS and the various xsave/xrstor etc. builtins,
    pedantically none of those builtins do anything that leaf functions
    are forbidden to do (having callbacks, calling functions from current TU,
    longjump into the current TU), but sometimes non-leaf is also used on
    really complex functions to prevent some unwanted optimizations.
    That said, haven't run into any problems as is with the patch.

    2023-12-20  Jakub Jelinek  <jakub@redhat.com>

            PR target/112962
            * config/i386/i386-builtins.cc (ix86_builtins): Increase by one
            element.
            (def_builtin): If not -fnon-call-exceptions, set TREE_NOTHROW on
            the builtin FUNCTION_DECL.  Add leaf attribute to DECL_ATTRIBUTES.
            (ix86_add_new_builtins): Likewise.

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2023-12-20 11:02 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 14:59 [Bug target/112962] New: [14 Regression] ICE: SIGSEGV in operator()<rtx_def*, rtx_def*> (recog.h:431) with -fexceptions -mssse3 and __builtin_ia32_pabsd128() zsojka at seznam dot cz
2023-12-12  7:21 ` [Bug target/112962] " rguenth at gcc dot gnu.org
2023-12-12  9:05 ` ubizjak at gmail dot com
2023-12-12  9:36 ` jakub at gcc dot gnu.org
2023-12-12  9:38 ` jakub at gcc dot gnu.org
2023-12-12  9:38 ` ubizjak at gmail dot com
2023-12-12  9:39 ` jakub at gcc dot gnu.org
2023-12-12  9:54 ` ubizjak at gmail dot com
2023-12-12 10:03 ` jakub at gcc dot gnu.org
2023-12-12 10:08 ` jakub at gcc dot gnu.org
2023-12-12 10:12 ` ubizjak at gmail dot com
2023-12-12 10:15 ` ubizjak at gmail dot com
2023-12-12 10:36 ` jakub at gcc dot gnu.org
2023-12-12 11:06 ` liuhongt at gcc dot gnu.org
2023-12-12 11:08 ` liuhongt at gcc dot gnu.org
2023-12-12 11:24 ` jakub at gcc dot gnu.org
2023-12-12 11:26 ` jakub at gcc dot gnu.org
2023-12-12 22:59 ` pinskia at gcc dot gnu.org
2023-12-13 10:34 ` cvs-commit at gcc dot gnu.org
2023-12-13 11:10 ` jakub at gcc dot gnu.org
2023-12-20 11:02 ` cvs-commit at gcc dot gnu.org

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