public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
@ 2024-01-10 20:54 zsojka at seznam dot cz
  2024-01-10 21:06 ` [Bug tree-optimization/113315] " zsojka at seznam dot cz
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-10 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113315
           Summary: during GIMPLE pass: bitintlower0 ICE: in
                    lower_mergeable_stmt, at gimple-lower-bitint.cc:2310
                    with _BitInt() used as array index
           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 57028
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57028&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc testcase.c 
during GIMPLE pass: bitintlower0
testcase.c: In function 'foo':
testcase.c:5:1: internal compiler error: in lower_mergeable_stmt, at
gimple-lower-bitint.cc:2310
    5 | foo (void)
      | ^~~
0xd7f264 lower_mergeable_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:2310
0x266953d lower_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:5320
0x266bf59 gimple_lower_bitint
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:6514
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-7116-20240110185507-g52e809d5cf3-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-7116-20240110185507-g52e809d5cf3-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20240110 (experimental) (GCC)

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

* [Bug tree-optimization/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
@ 2024-01-10 21:06 ` zsojka at seznam dot cz
  2024-01-10 21:24 ` zsojka at seznam dot cz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-10 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> ---
Created attachment 57029
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57029&action=edit
probably related testcase, ICEing elsewhere at -O1

Compiler output with the other testcase at -O1:
$ x86_64-pc-linux-gnu-gcc -O testcase2.c 
during GIMPLE pass: ccp
testcase2.c: In function 'foo':
testcase2.c:8:1: internal compiler error: in extended_tree, at tree.h:6449
    8 | }
      | ^
0xf083fe wi::extended_tree<128>::extended_tree(tree_node const*)
        /repo/gcc-trunk/gcc/tree.h:6449
0xf083fe wi::extended_tree<128>::extended_tree(tree_node const*)
        /repo/gcc-trunk/gcc/tree.h:6446
0x1164b80 generic_wide_int<wi::extended_tree<128> >::generic_wide_int<tree_node
const*>(tree_node const* const&)
        /repo/gcc-trunk/gcc/wide-int.h:847
0x1164b80 poly_int<1u, generic_wide_int<wi::extended_tree<128> >
>::poly_int<tree_node const*>(poly_int_full, tree_node const* const&)
        /repo/gcc-trunk/gcc/poly-int.h:467
0x1164b80 poly_int<1u, generic_wide_int<wi::extended_tree<128> >
>::poly_int<tree_node const*>(tree_node const* const&)
        /repo/gcc-trunk/gcc/poly-int.h:453
0x1164b80 wi::to_poly_offset(tree_node const*)
        /repo/gcc-trunk/gcc/tree.h:6549
0x1164b80 fold_const_aggregate_ref_1(tree_node*, tree_node* (*)(tree_node*))
        /repo/gcc-trunk/gcc/gimple-fold.cc:8358
0x1165c34 gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
        /repo/gcc-trunk/gcc/gimple-fold.cc:7670
0x162f8ae ccp_fold
        /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:1288
0x162f8ae evaluate_stmt
        /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2226
0x1631faf visit_assignment
        /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2861
0x16ee563 ssa_propagation_engine::simulate_stmt(gimple*)
        /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:221
0x16ee83a ssa_propagation_engine::simulate_block(basic_block_def*)
        /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:328
0x16eed73 ssa_propagation_engine::ssa_propagate()
        /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:478
0x1627509 do_ssa_ccp
        /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2980
0x1627509 execute
        /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:3026
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] 7+ messages in thread

* [Bug tree-optimization/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
  2024-01-10 21:06 ` [Bug tree-optimization/113315] " zsojka at seznam dot cz
@ 2024-01-10 21:24 ` zsojka at seznam dot cz
  2024-01-11 12:15 ` [Bug c/113315] " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-10 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

Compiler output for testcase3.c:
$ x86_64-pc-linux-gnu-gcc testcase3.c
during GIMPLE pass: bitintlower0
testcase3.c: In function 'foo':
testcase3.c:5:1: internal compiler error: in lower_stmt, at
gimple-lower-bitint.cc:5421
    5 | foo (void)
      | ^~~
0xd7fc87 lower_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:5421
0x266bf59 gimple_lower_bitint
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:6514
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] 7+ messages in thread

* [Bug c/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
  2024-01-10 21:06 ` [Bug tree-optimization/113315] " zsojka at seznam dot cz
  2024-01-10 21:24 ` zsojka at seznam dot cz
@ 2024-01-11 12:15 ` jakub at gcc dot gnu.org
  2024-01-12 16:12 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-11 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-01-11
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

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

Untested fix.

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

* [Bug c/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-01-11 12:15 ` [Bug c/113315] " jakub at gcc dot gnu.org
@ 2024-01-12 16:12 ` cvs-commit at gcc dot gnu.org
  2024-01-12 16:14 ` jakub at gcc dot gnu.org
  2024-01-20 17:08 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-12 16:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:95440171d0e615b0a1aa6863e41ba30df86ac3f4

commit r14-7200-g95440171d0e615b0a1aa6863e41ba30df86ac3f4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 12 17:11:49 2024 +0100

    c: Avoid _BitInt indexes > sizetype in ARRAY_REFs [PR113315]

    When build_array_ref doesn't use ARRAY_REF, it casts the index to sizetype
    already, performs POINTER_PLUS_EXPR and then dereferences.
    While when emitting ARRAY_REF, we try to keep index expression as is in
    whatever type it had, which is reasonable e.g. for signed or unsigned types
    narrower than sizetype for loop optimizations etc.
    But if the index is wider than sizetype, we are unnecessarily computing
    bits beyond what is needed.  For {,unsigned }__int128 on 64-bit arches
    or {,unsigned }long long on 32-bit arches we've been doing that for
decades,
    so the following patch doesn't propose to change that (might be stage1
    material), but for _BitInt at least the _BitInt lowering code doesn't
expect
    to see large/huge _BitInt in the ARRAY_REF indexes, I was expecting one
    would see just casts of those to sizetype.

    So, the following patch makes sure that large/huge _BitInt indexes don't
    appear in ARRAY_REFs.

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

            PR c/113315
            * c-typeck.cc (build_array_ref): If index has BITINT_TYPE type with
            precision larger than sizetype precision, convert it to sizetype.

            * gcc.dg/bitint-65.c: New test.
            * gcc.dg/bitint-66.c: New test.

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

* [Bug c/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-01-12 16:12 ` cvs-commit at gcc dot gnu.org
@ 2024-01-12 16:14 ` jakub at gcc dot gnu.org
  2024-01-20 17:08 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-12 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index
  2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-01-12 16:14 ` jakub at gcc dot gnu.org
@ 2024-01-20 17:08 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-20 17:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 20:54 [Bug tree-optimization/113315] New: during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index zsojka at seznam dot cz
2024-01-10 21:06 ` [Bug tree-optimization/113315] " zsojka at seznam dot cz
2024-01-10 21:24 ` zsojka at seznam dot cz
2024-01-11 12:15 ` [Bug c/113315] " jakub at gcc dot gnu.org
2024-01-12 16:12 ` cvs-commit at gcc dot gnu.org
2024-01-12 16:14 ` jakub at gcc dot gnu.org
2024-01-20 17:08 ` pinskia 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).