public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
@ 2024-01-15 20:26 zsojka at seznam dot cz
  2024-01-16 11:19 ` [Bug tree-optimization/113408] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-15 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113408
           Summary: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at
                    -O 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 57094
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57094&action=edit
reduced testcase

This is reduced from gcc.c-torture/execute/pr82387.c, when testsuite is run
with -Dint=_BitInt($RANDOM)

Compiler output:
$ 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 handle_cast, at
gimple-lower-bitint.cc:1539
    8 | foo(void)
      | ^~~
0xd88b9a handle_cast
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:1539
0x2707c50 handle_operand
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:815
0x2713592 lower_mergeable_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:2462
0x2717a7d lower_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:5336
0x271a499 gimple_lower_bitint
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:6530
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-7255-20240115165927-g6c703b4eb68-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/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-7255-20240115165927-g6c703b4eb68-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240115 (experimental) (GCC)

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

* [Bug tree-optimization/113408] ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
  2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
@ 2024-01-16 11:19 ` jakub at gcc dot gnu.org
  2024-01-16 11:58 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-16 11:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly adjusted:
struct A { _BitInt(713) b; } g;
int f;

void
foo (void)
{
  struct A j = g;
  if (j.b)
    f = 0;
}

The problem is that SRA decides to change:
  j = g;
  _1 = j.b;
  if (_1 != 0)
to
  j_7 = MEM[(struct A *)&g];
  _1 = VIEW_CONVERT_EXPR<_BitInt(713)>(j_7);
  if (_1 != 0)
where j_7 has _BitInt(768) type, and handle_cast doesn't seem to handle that.
So, we need to handle it there, and ideally also tweak SRA so that it keeps the
bitints as is even if they don't have precision in multiple of bytes or words
or whatever SRA rounds to.

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

* [Bug tree-optimization/113408] ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
  2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
  2024-01-16 11:19 ` [Bug tree-optimization/113408] " jakub at gcc dot gnu.org
@ 2024-01-16 11:58 ` jakub at gcc dot gnu.org
  2024-01-17 12:57 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-16 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

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
   Last reconfirmed|                            |2024-01-16
     Ever confirmed|0                           |1

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

Untested fix.

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

* [Bug tree-optimization/113408] ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
  2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
  2024-01-16 11:19 ` [Bug tree-optimization/113408] " jakub at gcc dot gnu.org
  2024-01-16 11:58 ` jakub at gcc dot gnu.org
@ 2024-01-17 12:57 ` cvs-commit at gcc dot gnu.org
  2024-01-17 12:58 ` jakub at gcc dot gnu.org
  2024-01-20 17:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-17 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:2fb78d431ff3c05997ef31837d6eb319d84a4239

commit r14-8184-g2fb78d431ff3c05997ef31837d6eb319d84a4239
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 17 13:55:50 2024 +0100

    lower-bitint: Fix up VIEW_CONVERT_EXPR handling [PR113408]

    Unlike NOP_EXPR/CONVERT_EXPR which are GIMPLE_UNARY_RHS, VIEW_CONVERT_EXPR
    is GIMPLE_SINGLE_RHS and so gimple_assign_rhs1 contains the operand wrapped
    in VIEW_CONVERT_EXPR tree.

    So, to handle it like other casts we need to look through it.

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

            PR tree-optimization/113408
            * gimple-lower-bitint.cc (bitint_large_huge::handle_stmt): For
            VIEW_CONVERT_EXPR, pass TREE_OPERAND (rhs1, 0) rather than rhs1
            to handle_cast.

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

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

* [Bug tree-optimization/113408] ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
  2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-01-17 12:57 ` cvs-commit at gcc dot gnu.org
@ 2024-01-17 12:58 ` jakub at gcc dot gnu.org
  2024-01-20 17:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-17 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug tree-optimization/113408] ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt()
  2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-01-17 12:58 ` jakub at gcc dot gnu.org
@ 2024-01-20 17:10 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-20 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 20:26 [Bug tree-optimization/113408] New: ICE: in handle_cast, at gimple-lower-bitint.cc:1539 at -O with _BitInt() zsojka at seznam dot cz
2024-01-16 11:19 ` [Bug tree-optimization/113408] " jakub at gcc dot gnu.org
2024-01-16 11:58 ` jakub at gcc dot gnu.org
2024-01-17 12:57 ` cvs-commit at gcc dot gnu.org
2024-01-17 12:58 ` jakub at gcc dot gnu.org
2024-01-20 17:10 ` 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).