public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
@ 2023-12-13 19:58 zsojka at seznam dot cz
  2023-12-13 20:05 ` [Bug rtl-optimization/113003] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zsojka at seznam dot cz @ 2023-12-13 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113003
           Summary: ICE: in expand_mult, at expmed.cc:3603 at -O with
                    __builtin_mul_overflow_p() and _BitInt()
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-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 56873
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56873&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c 
during RTL pass: expand
testcase.c: In function 'foo':
testcase.c:6:7: internal compiler error: in expand_mult, at expmed.cc:3603
    6 |   b = __builtin_mul_overflow_p(a, (_BitInt(383))3545869000730815518 <<
64 << 4, 0);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
0x7573f8 expand_mult(machine_mode, rtx_def*, rtx_def*, rtx_def*, int, bool)
        /repo/gcc-trunk/gcc/expmed.cc:3603
0x11e7a3c expand_arith_overflow
        /repo/gcc-trunk/gcc/internal-fn.cc:2722
0xf74a6f expand_call_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:2744
0xf74a6f expand_gimple_stmt_1
        /repo/gcc-trunk/gcc/cfgexpand.cc:3900
0xf74a6f expand_gimple_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:4064
0xf7b04e expand_gimple_basic_block
        /repo/gcc-trunk/gcc/cfgexpand.cc:6120
0xf7cd27 execute
        /repo/gcc-trunk/gcc/cfgexpand.cc:6855
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.

This is with g373a85a82650d9938adb02a14686049cbcbe6892 ;
g348874f0baac0f22c98ab11abbfa65fd172f6bdd breaks the build for me (as can be
also seen on gcc-regression)

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

* [Bug rtl-optimization/113003] ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
  2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
@ 2023-12-13 20:05 ` mpolacek at gcc dot gnu.org
  2023-12-14 11:58 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-12-13 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2023-12-13

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

* [Bug rtl-optimization/113003] ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
  2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
  2023-12-13 20:05 ` [Bug rtl-optimization/113003] " mpolacek at gcc dot gnu.org
@ 2023-12-14 11:58 ` jakub at gcc dot gnu.org
  2023-12-14 12:04 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-14 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly reduced:
int
foo (_BitInt(7) x)
{
  return __builtin_mul_overflow_p (x,
1046555807606105294475452482332716433408wb, 0);
}
Ugh, another special case where we don't detect the need to lower, next to
storing large/huge INTEGER_CSTs or the large/huge INTEGER_CST to floating
casts.

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

* [Bug rtl-optimization/113003] ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
  2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
  2023-12-13 20:05 ` [Bug rtl-optimization/113003] " mpolacek at gcc dot gnu.org
  2023-12-14 11:58 ` jakub at gcc dot gnu.org
@ 2023-12-14 12:04 ` jakub at gcc dot gnu.org
  2023-12-15  9:11 ` cvs-commit at gcc dot gnu.org
  2023-12-15  9:19 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-14 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
int
bar (unsigned __int128 x)
{
  return __builtin_sub_overflow_p (340282366920938463463374607431768211457uwb,
x, 0);
}

while it doesn't ICE is also something that has to be lowered and not left
until expansion.

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

* [Bug rtl-optimization/113003] ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
  2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-12-14 12:04 ` jakub at gcc dot gnu.org
@ 2023-12-15  9:11 ` cvs-commit at gcc dot gnu.org
  2023-12-15  9:19 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-15  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:d50d3d0a688e8dac31b307b3aad3fbc99283ebc4

commit r14-6579-gd50d3d0a688e8dac31b307b3aad3fbc99283ebc4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 15 10:10:58 2023 +0100

    lower-bitint: Fix .{ADD,SUB,MUL}_OVERFLOW with _BitInt large/huge
INTEGER_CST arguments [PR113003]

    As shown in the testcase, .{ADD,SUB,MUL}_OVERFLOW calls are another
    exception to the middle/large/huge _BitInt discovery through SSA_NAMEs
    next to stores of INTEGER_CSTs to memory and their conversions to
    floating point.
    The calls can have normal COMPLEX_TYPE with INTEGER_TYPE elts return type
    (or BITINT_TYPE with small precision) and one of the arguments can be
    SSA_NAME with an INTEGER_TYPE or small BITINT_TYPE as well; still, when
    there is an INTEGER_CST argument with large/huge BITINT_TYPE, we need to
    lower it that way.

    2023-12-15  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/113003
            * gimple-lower-bitint.cc (arith_overflow_arg_kind): New function.
            (gimple_lower_bitint): Use it to catch .{ADD,SUB,MUL}_OVERFLOW
            calls with large/huge INTEGER_CST arguments.

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

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

* [Bug rtl-optimization/113003] ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt()
  2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2023-12-15  9:11 ` cvs-commit at gcc dot gnu.org
@ 2023-12-15  9:19 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-15  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-12-15  9:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 19:58 [Bug rtl-optimization/113003] New: ICE: in expand_mult, at expmed.cc:3603 at -O with __builtin_mul_overflow_p() and _BitInt() zsojka at seznam dot cz
2023-12-13 20:05 ` [Bug rtl-optimization/113003] " mpolacek at gcc dot gnu.org
2023-12-14 11:58 ` jakub at gcc dot gnu.org
2023-12-14 12:04 ` jakub at gcc dot gnu.org
2023-12-15  9:11 ` cvs-commit at gcc dot gnu.org
2023-12-15  9:19 ` 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).