public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
@ 2023-12-22 18:54 zsojka at seznam dot cz
  2023-12-22 21:04 ` [Bug tree-optimization/113119] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2023-12-22 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113119
           Summary: ICE: verify_ssa failed: definition in block 18 does
                    not dominate use in block 4 at -O1 with _BitInt
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

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

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c 
testcase.c: In function 'foo':
testcase.c:6:1: error: definition in block 18 does not dominate use in block 4
    6 | foo(_BitInt(4058) d)
      | ^~~
for SSA_NAME: _55 in statement:
_3 = _55;
during GIMPLE pass: bitintlower
testcase.c:6:1: internal compiler error: verify_ssa failed
0x177189f verify_ssa(bool, bool)
        /repo/gcc-trunk/gcc/tree-ssa.cc:1203
0x13c53e5 execute_function_todo
        /repo/gcc-trunk/gcc/passes.cc:2095
0x13c584e execute_todo
        /repo/gcc-trunk/gcc/passes.cc:2142
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-6806-20231222122934-gcefae511ed7-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-6806-20231222122934-gcefae511ed7-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20231222 (experimental) (GCC)

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

* [Bug tree-optimization/113119] ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
  2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
@ 2023-12-22 21:04 ` jakub at gcc dot gnu.org
  2023-12-23  7:41 ` zsojka at seznam dot cz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-22 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Without the second redundant __builtin_add_overflow, we get
  a.0_1 = a;
  _7 = .ADD_OVERFLOW (a.0_1, 0);
  _2 = REALPART_EXPR <_7>;
  _3 = IMAGPART_EXPR <_7>;
  _4 = (_Bool) _3;
  c = _4;
  _5 = (_BitInt(8)) _2;
  b = _5;
before bitint lowering and lower it well, but the redundant call results in
  a.0_1 = a;
  _7 = .ADD_OVERFLOW (a.0_1, 0);
  _2 = IMAGPART_EXPR <_7>;
  _3 = (_Bool) _2;
  c = _3;
  _4 = REALPART_EXPR <_7>;
  _5 = (_BitInt(8)) _4;
  b = _5;
and optimizable_arith_overflow doesn't flag that as non-optimizable, so
the bitint lowering of .ADD_OVERFLOW happens in that case on the REALPART_EXPR
stmt.
optimizable_arith_overflow checks if both REALPART_EXPR and IMAGPART_EXPR
appear in the same bb (and that there are no other uses), but doesn't check
that REALPART_EXPR is first.  Either it should check that or perhaps allow it
first but require that it is not used in statements before the REALPART_EXPR.

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

* [Bug tree-optimization/113119] ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
  2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
  2023-12-22 21:04 ` [Bug tree-optimization/113119] " jakub at gcc dot gnu.org
@ 2023-12-23  7:41 ` zsojka at seznam dot cz
  2023-12-23  9:50 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2023-12-23  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> ---
Created attachment 56925
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56925&action=edit
slightly less reduced testcase, ICEing elsewhere

The original testcase was ICEing at a different place, as does this testcase:

$ x86_64-pc-linux-gnu-gcc -O testcase.c 
during GIMPLE pass: bitintlower
testcase.c: In function 'foo':
testcase.c:8:1: internal compiler error: in operator[], at vec.h:910
    8 | foo(_BitInt(4058) d)
      | ^~~
0x8a0a88 vec<tree_node*, va_gc, vl_embed>::operator[](unsigned int)
        /repo/gcc-trunk/gcc/vec.h:910
0x8a0c6e vec<equiv_chain*, va_heap, vl_embed>::operator[](unsigned int)
        /repo/gcc-trunk/gcc/value-relation.cc:736
0x8a0c6e vec<equiv_chain*, va_heap, vl_ptr>::operator[](unsigned int)
        /repo/gcc-trunk/gcc/vec.h:1599
0x8a0c6e equiv_oracle::add_equiv_to_block(basic_block_def*, bitmap_head*)
        /repo/gcc-trunk/gcc/value-relation.cc:721
0x185e5c2 equiv_oracle::register_relation(basic_block_def*, relation_kind_t,
tree_node*, tree_node*)
        /repo/gcc-trunk/gcc/value-relation.cc:675
0x26597e9 fold_using_range::range_of_range_op(vrange&,
gimple_range_op_handler&, fur_source&)
        /repo/gcc-trunk/gcc/gimple-range-fold.cc:687
0x2659bf2 fold_using_range::fold_stmt(vrange&, gimple*, fur_source&,
tree_node*)
        /repo/gcc-trunk/gcc/gimple-range-fold.cc:602
0x2641c7e gimple_ranger::fold_range_internal(vrange&, gimple*, tree_node*)
        /repo/gcc-trunk/gcc/gimple-range.cc:265
0x2641c7e gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*)
        /repo/gcc-trunk/gcc/gimple-range.cc:326
0x264597a gimple_ranger::range_of_expr(vrange&, tree_node*, gimple*)
        /repo/gcc-trunk/gcc/gimple-range.cc:134
0x261e312 range_to_prec
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:1980
0x2620acb handle_operand_addr
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:2025
0x26217e7 lower_muldiv_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:3365
0x2635599 gimple_lower_bitint
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:6490
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.

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

* [Bug tree-optimization/113119] ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
  2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
  2023-12-22 21:04 ` [Bug tree-optimization/113119] " jakub at gcc dot gnu.org
  2023-12-23  7:41 ` zsojka at seznam dot cz
@ 2023-12-23  9:50 ` jakub at gcc dot gnu.org
  2024-01-08 13:00 ` cvs-commit at gcc dot gnu.org
  2024-01-08 13:02 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-23  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

So far lightly tested patch.  Fixes both testcases.

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

* [Bug tree-optimization/113119] ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
  2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-12-23  9:50 ` jakub at gcc dot gnu.org
@ 2024-01-08 13:00 ` cvs-commit at gcc dot gnu.org
  2024-01-08 13:02 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-08 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:7590d975ecfdae4f112b5086c017101c08f07e3e

commit r14-7000-g7590d975ecfdae4f112b5086c017101c08f07e3e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 8 13:57:26 2024 +0100

    lower-bitint: Punt .*_OVERFLOW optimization if cast from IMAGPART_EXPR
appears before REALPART_EXPR [PR113119]

    _BitInt lowering for .{ADD,SUB,MUL}_OVERFLOW calls which have both
    REALPART_EXPR and IMAGPART_EXPR used and have a cast from the IMAGPART_EXPR
    to a boolean or normal integral type lowers them at the point of
    the REALPART_EXPR statement (which is especially needed if the lhs of
    the call is complex with large/huge _BitInt element type); we emit the
    stmt to set the lhs of the cast at the same spot as well.
    Normally, the lowering of __builtin_{add,sub,mul}_overflow arranges
    the REALPART_EXPR to come before IMAGPART_EXPR, followed by cast from that,
    but as the testcase shows, a redundant __builtin_*_overflow call and VN
    can reorder those and we then ICE because the def-stmt of the former cast
    from IMAGPART_EXPR may appear after its uses.
    We already check that all of REALPART_EXPR, IMAGPART_EXPR and the cast
    from the latter appear in the same bb as the .{ADD,SUB,MUL}_OVERFLOW call
    in the optimization, the following patch just extends it to make sure
    cast appears after REALPART_EXPR; if not, we punt on the optimization and
    expand it as a store of a complex _BitInt on the location of the ifn call.
    Only the testcase in the testsuite is changed by the patch, all other
    __builtin_*_overflow* calls in the bitint* tests (and there are quite a
few)
    have REALPART_EXPR first.

    2024-01-08  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/113119
            * gimple-lower-bitint.cc (optimizable_arith_overflow): Punt if
            both REALPART_EXPR and cast from IMAGPART_EXPR appear, but cast
            is before REALPART_EXPR.

            * gcc.dg/bitint-61.c: New test.

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

* [Bug tree-optimization/113119] ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt
  2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-01-08 13:00 ` cvs-commit at gcc dot gnu.org
@ 2024-01-08 13:02 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-08 13:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|ASSIGNED                    |RESOLVED

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

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

end of thread, other threads:[~2024-01-08 13:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-22 18:54 [Bug tree-optimization/113119] New: ICE: verify_ssa failed: definition in block 18 does not dominate use in block 4 at -O1 with _BitInt zsojka at seznam dot cz
2023-12-22 21:04 ` [Bug tree-optimization/113119] " jakub at gcc dot gnu.org
2023-12-23  7:41 ` zsojka at seznam dot cz
2023-12-23  9:50 ` jakub at gcc dot gnu.org
2024-01-08 13:00 ` cvs-commit at gcc dot gnu.org
2024-01-08 13:02 ` 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).