public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
@ 2024-06-18 18:43 zsojka at seznam dot cz
  2024-06-18 20:35 ` [Bug tree-optimization/115544] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2024-06-18 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115544
           Summary: ICE: in lower_complexexpr_stmt, at
                    gimple-lower-bitint.cc:4719 with -O -fno-tree-fre
                    -fno-tree-ccp -fno-tree-forwprop and _BitInt()
                    __builtin_mul_overflow()
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
          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 58465
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58465&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop
testcase.c 
during GIMPLE pass: bitintlower
testcase.c: In function 'foo':
testcase.c:5:1: internal compiler error: in lower_complexexpr_stmt, at
gimple-lower-bitint.cc:4719
    5 | foo()
      | ^~~
0xdad936 lower_complexexpr_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:4719
0xdad936 lower_stmt
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:5708
0x27cf3f1 gimple_lower_bitint
        /repo/gcc-trunk/gcc/gimple-lower-bitint.cc:6926
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-r15-1418-20240618085924-gadadb5c7ba0-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/15.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 --enable-libsanitizer
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r15-1418-20240618085924-gadadb5c7ba0-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240618 (experimental) (GCC)

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
@ 2024-06-18 20:35 ` pinskia at gcc dot gnu.org
  2024-06-18 20:36 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-18 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|x86_64-pc-linux-gnu         |
             Target|x86_64-pc-linux-gnu         |x86_64-pc-linux-gnu
                   |                            |aarch64-*-*
      Known to fail|                            |14.1.0
      Known to work|14.1.1                      |
          Component|middle-end                  |tree-optimization

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. ICEs for me with released GCC 14.1.0 on both x86_64 and aarch64.

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
  2024-06-18 20:35 ` [Bug tree-optimization/115544] " pinskia at gcc dot gnu.org
@ 2024-06-18 20:36 ` pinskia at gcc dot gnu.org
  2024-06-18 22:14 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-18 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-06-18
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
  2024-06-18 20:35 ` [Bug tree-optimization/115544] " pinskia at gcc dot gnu.org
  2024-06-18 20:36 ` pinskia at gcc dot gnu.org
@ 2024-06-18 22:14 ` pinskia at gcc dot gnu.org
  2024-06-19 13:58 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-18 22:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the gimple stmt/complex_expr in this case:
  _6 = COMPLEX_EXPR <a.0_1, 0>;


where _6 is fully unused.

Complex lowering changes:
  _6 = COMPLEX_EXPR <a.0_1, 0>;
  _2 = REALPART_EXPR <_6>;

into:
  _6 = COMPLEX_EXPR <a.0_1, 0>;
  _2 = a.0_1;

Which is totally correct though it does not do any DCE.
I am not sure if complex lowering should do some simple DCE or if it matters if
it does not do it.

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-06-18 22:14 ` pinskia at gcc dot gnu.org
@ 2024-06-19 13:58 ` jakub at gcc dot gnu.org
  2024-06-19 19:12 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-19 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

So far lightly tested fix.

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-06-19 13:58 ` jakub at gcc dot gnu.org
@ 2024-06-19 19:12 ` cvs-commit at gcc dot gnu.org
  2024-06-20  8:27 ` cvs-commit at gcc dot gnu.org
  2024-06-20  8:30 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-19 19:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:25860fd2a674373a6476af5ff0bd92354fc53d06

commit r15-1455-g25860fd2a674373a6476af5ff0bd92354fc53d06
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 19 21:10:39 2024 +0200

    bitint: Fix up lowering of COMPLEX_EXPR [PR115544]

    We don't really support _Complex _BitInt(N), the only place we use
    bitint complex types is for the .{ADD,SUB,MUL}_OVERFLOW internal function
    results and COMPLEX_EXPR in the usual case should be either not present
    yet because the ifns weren't folded and will be lowered, or optimized
    into something simpler, because normally the complex bitint should be
    used just for extracting the 2 subparts from it.
    Still, with disabled optimizations it can occassionally happen that it
    appears in the IL and that is why there is support for lowering those,
    but it doesn't handle optimizing those too much, so if it uses SSA_NAME,
    it relies on them having a backing VAR_DECL during the lowering.
    This is normally achieves through the
                          && ((is_gimple_assign (use_stmt)
                               && (gimple_assign_rhs_code (use_stmt)
                                   != COMPLEX_EXPR))
                              || gimple_code (use_stmt) == GIMPLE_COND)
    hunk in gimple_lower_bitint, but as the following testcase shows, there
    is one thing I've missed, the load optimization isn't guarded by the
    above stuff.  So, either we'd need to add support for loads to
    lower_complexexpr_stmt, or because they should be really rare, this
    patch just disables the load optimization if at least one load use is
    a COMPLEX_EXPR (like we do already for PHIs, calls, asm).

    2024-06-19  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/115544
            * gimple-lower-bitint.cc (gimple_lower_bitint): Disable optimizing
            loads used by COMPLEX_EXPR operands.

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

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-06-19 19:12 ` cvs-commit at gcc dot gnu.org
@ 2024-06-20  8:27 ` cvs-commit at gcc dot gnu.org
  2024-06-20  8:30 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-20  8:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:f79e909a11672f2c5b04239d8d9376b900c5b295

commit r14-10327-gf79e909a11672f2c5b04239d8d9376b900c5b295
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 19 21:10:39 2024 +0200

    bitint: Fix up lowering of COMPLEX_EXPR [PR115544]

    We don't really support _Complex _BitInt(N), the only place we use
    bitint complex types is for the .{ADD,SUB,MUL}_OVERFLOW internal function
    results and COMPLEX_EXPR in the usual case should be either not present
    yet because the ifns weren't folded and will be lowered, or optimized
    into something simpler, because normally the complex bitint should be
    used just for extracting the 2 subparts from it.
    Still, with disabled optimizations it can occassionally happen that it
    appears in the IL and that is why there is support for lowering those,
    but it doesn't handle optimizing those too much, so if it uses SSA_NAME,
    it relies on them having a backing VAR_DECL during the lowering.
    This is normally achieves through the
                          && ((is_gimple_assign (use_stmt)
                               && (gimple_assign_rhs_code (use_stmt)
                                   != COMPLEX_EXPR))
                              || gimple_code (use_stmt) == GIMPLE_COND)
    hunk in gimple_lower_bitint, but as the following testcase shows, there
    is one thing I've missed, the load optimization isn't guarded by the
    above stuff.  So, either we'd need to add support for loads to
    lower_complexexpr_stmt, or because they should be really rare, this
    patch just disables the load optimization if at least one load use is
    a COMPLEX_EXPR (like we do already for PHIs, calls, asm).

    2024-06-19  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/115544
            * gimple-lower-bitint.cc (gimple_lower_bitint): Disable optimizing
            loads used by COMPLEX_EXPR operands.

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

    (cherry picked from commit 25860fd2a674373a6476af5ff0bd92354fc53d06)

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

* [Bug tree-optimization/115544] ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow()
  2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-06-20  8:27 ` cvs-commit at gcc dot gnu.org
@ 2024-06-20  8:30 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-06-20  8:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 14.2+ and 15.1+.

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

end of thread, other threads:[~2024-06-20  8:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-18 18:43 [Bug middle-end/115544] New: ICE: in lower_complexexpr_stmt, at gimple-lower-bitint.cc:4719 with -O -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop and _BitInt() __builtin_mul_overflow() zsojka at seznam dot cz
2024-06-18 20:35 ` [Bug tree-optimization/115544] " pinskia at gcc dot gnu.org
2024-06-18 20:36 ` pinskia at gcc dot gnu.org
2024-06-18 22:14 ` pinskia at gcc dot gnu.org
2024-06-19 13:58 ` jakub at gcc dot gnu.org
2024-06-19 19:12 ` cvs-commit at gcc dot gnu.org
2024-06-20  8:27 ` cvs-commit at gcc dot gnu.org
2024-06-20  8:30 ` 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).