public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
@ 2022-06-13 17:44 gscfq@t-online.de
  2022-06-14  6:22 ` [Bug target/105951] " ubizjak at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-06-13 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105951
           Summary: [12/13 Regression] ICE in emit_store_flag, at
                    expmed.cc:6027
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started between 20211219 and 20220109, at -O1+,
with gcc.target/i386/pr98737-2.c and gcc.target/i386/pr98737-4.c :


$ gcc-13-20220612 -c pr98737-2.c -O2 -m32 -march=i386
during RTL pass: expand
pr98737-2.c: In function 'f1':
pr98737-2.c:20:10: internal compiler error: Segmentation fault
   20 |   return __atomic_sub_fetch (&a, x, __ATOMIC_RELEASE) <= 0;
      |          ^~~~~~~~~~~~~~~~~~
0xc2a33f crash_signal
        ../../gcc/toplev.cc:322
0x8cf362 emit_store_flag(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode,
int, int)
        ../../gcc/expmed.cc:6027
0x8cffd8 emit_store_flag_force(rtx_def*, rtx_code, rtx_def*, rtx_def*,
machine_mode, int, int)
        ../../gcc/expmed.cc:6170
0x7a9946 expand_ifn_atomic_op_fetch_cmp_0(gcall*)
        ../../gcc/builtins.cc:6374
0x7d0557 expand_call_stmt
        ../../gcc/cfgexpand.cc:2737
0x7d0557 expand_gimple_stmt_1
        ../../gcc/cfgexpand.cc:3869
0x7d0557 expand_gimple_stmt
        ../../gcc/cfgexpand.cc:4033
0x7d5707 expand_gimple_basic_block
        ../../gcc/cfgexpand.cc:6085
0x7d81ce execute
        ../../gcc/cfgexpand.cc:6811

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

* [Bug target/105951] [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
@ 2022-06-14  6:22 ` ubizjak at gmail dot com
  2022-06-14  6:24 ` ubizjak at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2022-06-14  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2022-06-14
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.3

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
Confirmed, expand_ifn_atomic_op_fetch_cmp_0 is not prepared for case where
expand_atomic_fetch_op returns NULL_RTX:

  rtx result = expand_atomic_fetch_op (gen_reg_rtx (mode), mem, op,
                                       code, model, true);
  if (lhs)
    {
      result = emit_store_flag_force (target, comp, result, const0_rtx, mode,
                                      0, 1);
      if (result != target)
        emit_move_insn (target, result);
    }

The compilation ICEs when NULL_RTX is passed to emit_store_flag_force.

CC author.

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

* [Bug target/105951] [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
  2022-06-14  6:22 ` [Bug target/105951] " ubizjak at gmail dot com
@ 2022-06-14  6:24 ` ubizjak at gmail dot com
  2022-06-14  8:18 ` [Bug middle-end/105951] " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2022-06-14  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #1)
> CC author.

g:6362627b27f395b054f359244fcfcb15ac0ac2ab

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

* [Bug middle-end/105951] [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
  2022-06-14  6:22 ` [Bug target/105951] " ubizjak at gmail dot com
  2022-06-14  6:24 ` ubizjak at gmail dot com
@ 2022-06-14  8:18 ` rguenth at gcc dot gnu.org
  2022-06-14 17:10 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-14  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug middle-end/105951] [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-06-14  8:18 ` [Bug middle-end/105951] " rguenth at gcc dot gnu.org
@ 2022-06-14 17:10 ` jakub at gcc dot gnu.org
  2022-06-16  9:01 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-14 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

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 #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 53136
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53136&action=edit
gcc13-pr105951.patch

Untested fix.

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

* [Bug middle-end/105951] [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-06-14 17:10 ` jakub at gcc dot gnu.org
@ 2022-06-16  9:01 ` cvs-commit at gcc dot gnu.org
  2022-06-16  9:37 ` [Bug middle-end/105951] [12 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-16  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS 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:6a27c430468cb85454b19cef881a1422580657ff

commit r13-1132-g6a27c430468cb85454b19cef881a1422580657ff
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 16 10:58:58 2022 +0200

    expand: Fix up IFN_ATOMIC_{BIT*,*CMP_0} expansion [PR105951]

    Both IFN_ATOMIC_BIT_TEST_AND_* and IFN_ATOMIC_*_FETCH_CMP_0 ifns
    are matched if their corresponding optab is implemented for the particular
    mode.  The fact that those optabs are implemented doesn't guarantee
    they will succeed though, they can just FAIL in their expansion.
    The expansion in that case uses expand_atomic_fetch_op as fallback, but
    as has been reported and and can be reproduced on the testcases,
    even those can fail and we didn't have any fallback after that.
    For IFN_ATOMIC_BIT_TEST_AND_* we actually have such calls.  One is
    done whenever we lost lhs of the ifn at some point in between matching
    it in tree-ssa-ccp.cc and expansion.  The following patch for that case
    just falls through and expands as if there was a lhs, creates a temporary
    for it.  For the other expand_atomic_fetch_op call in the same expander
    and for the only expand_atomic_fetch_op call in the other, this falls
    back the hard way, by constructing a CALL_EXPR to the call from which
    the ifn has been matched and expanding that.  Either it is lucky and
manages
    to expand inline, or it emits a libatomic API call.
    So that we don't have to rediscover which builtin function to call in the
    fallback, we record at tree-ssa-ccp.cc time gimple_call_fn (call) in
    an extra argument to the ifn.

    2022-06-16  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/105951
            * tree-ssa-ccp.cc (optimize_atomic_bit_test_and,
            optimize_atomic_op_fetch_cmp_0): Remember gimple_call_fn (call)
            as last argument to the internal functions.
            * builtins.cc (expand_ifn_atomic_bit_test_and): Adjust for the
            extra call argument to ifns.  If expand_atomic_fetch_op fails for
the
            lhs == NULL_TREE case, fall through into the optab code with
            gen_reg_rtx (mode) as target.  If second expand_atomic_fetch_op
            fails, construct a CALL_EXPR and expand that.
            (expand_ifn_atomic_op_fetch_cmp_0): Adjust for the extra call
argument
            to ifns.  If expand_atomic_fetch_op fails, construct a CALL_EXPR
and
            expand that.

            * gcc.target/i386/pr105951-1.c: New test.
            * gcc.target/i386/pr105951-2.c: New test.

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

* [Bug middle-end/105951] [12 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-06-16  9:01 ` cvs-commit at gcc dot gnu.org
@ 2022-06-16  9:37 ` jakub at gcc dot gnu.org
  2022-06-19 10:08 ` cvs-commit at gcc dot gnu.org
  2022-06-20  9:57 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-16  9:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13 Regression] ICE in   |[12 Regression] ICE in
                   |emit_store_flag, at         |emit_store_flag, at
                   |expmed.cc:6027              |expmed.cc:6027

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

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

* [Bug middle-end/105951] [12 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-06-16  9:37 ` [Bug middle-end/105951] [12 " jakub at gcc dot gnu.org
@ 2022-06-19 10:08 ` cvs-commit at gcc dot gnu.org
  2022-06-20  9:57 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-19 10:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:86e10e471fddfcacb0c02d02f30ab5bb2038e504

commit r12-8494-g86e10e471fddfcacb0c02d02f30ab5bb2038e504
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 16 10:58:58 2022 +0200

    expand: Fix up IFN_ATOMIC_{BIT*,*CMP_0} expansion [PR105951]

    Both IFN_ATOMIC_BIT_TEST_AND_* and IFN_ATOMIC_*_FETCH_CMP_0 ifns
    are matched if their corresponding optab is implemented for the particular
    mode.  The fact that those optabs are implemented doesn't guarantee
    they will succeed though, they can just FAIL in their expansion.
    The expansion in that case uses expand_atomic_fetch_op as fallback, but
    as has been reported and and can be reproduced on the testcases,
    even those can fail and we didn't have any fallback after that.
    For IFN_ATOMIC_BIT_TEST_AND_* we actually have such calls.  One is
    done whenever we lost lhs of the ifn at some point in between matching
    it in tree-ssa-ccp.cc and expansion.  The following patch for that case
    just falls through and expands as if there was a lhs, creates a temporary
    for it.  For the other expand_atomic_fetch_op call in the same expander
    and for the only expand_atomic_fetch_op call in the other, this falls
    back the hard way, by constructing a CALL_EXPR to the call from which
    the ifn has been matched and expanding that.  Either it is lucky and
manages
    to expand inline, or it emits a libatomic API call.
    So that we don't have to rediscover which builtin function to call in the
    fallback, we record at tree-ssa-ccp.cc time gimple_call_fn (call) in
    an extra argument to the ifn.

    2022-06-16  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/105951
            * tree-ssa-ccp.cc (optimize_atomic_bit_test_and,
            optimize_atomic_op_fetch_cmp_0): Remember gimple_call_fn (call)
            as last argument to the internal functions.
            * builtins.cc (expand_ifn_atomic_bit_test_and): Adjust for the
            extra call argument to ifns.  If expand_atomic_fetch_op fails for
the
            lhs == NULL_TREE case, fall through into the optab code with
            gen_reg_rtx (mode) as target.  If second expand_atomic_fetch_op
            fails, construct a CALL_EXPR and expand that.
            (expand_ifn_atomic_op_fetch_cmp_0): Adjust for the extra call
argument
            to ifns.  If expand_atomic_fetch_op fails, construct a CALL_EXPR
and
            expand that.

            * gcc.target/i386/pr105951-1.c: New test.
            * gcc.target/i386/pr105951-2.c: New test.

    (cherry picked from commit 6a27c430468cb85454b19cef881a1422580657ff)

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

* [Bug middle-end/105951] [12 Regression] ICE in emit_store_flag, at expmed.cc:6027
  2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-06-19 10:08 ` cvs-commit at gcc dot gnu.org
@ 2022-06-20  9:57 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-20  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 12.2 too.

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

end of thread, other threads:[~2022-06-20  9:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 17:44 [Bug c/105951] New: [12/13 Regression] ICE in emit_store_flag, at expmed.cc:6027 gscfq@t-online.de
2022-06-14  6:22 ` [Bug target/105951] " ubizjak at gmail dot com
2022-06-14  6:24 ` ubizjak at gmail dot com
2022-06-14  8:18 ` [Bug middle-end/105951] " rguenth at gcc dot gnu.org
2022-06-14 17:10 ` jakub at gcc dot gnu.org
2022-06-16  9:01 ` cvs-commit at gcc dot gnu.org
2022-06-16  9:37 ` [Bug middle-end/105951] [12 " jakub at gcc dot gnu.org
2022-06-19 10:08 ` cvs-commit at gcc dot gnu.org
2022-06-20  9:57 ` jakub 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).