public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64
@ 2024-08-25 13:37 zsojka at seznam dot cz
  2024-08-25 14:53 ` [Bug middle-end/116480] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zsojka at seznam dot cz @ 2024-08-25 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116480
           Summary: [15 Regression] ICE: in operand_subword_force, at
                    emit-rtl.cc:1824 at -O2 with
                    __builtin_stdc_has_single_bit() and _BitInt() on
                    aarch64
           Product: gcc
           Version: 15.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
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: aarch64-unknown-linux-gnu

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

Compiler output:
$ aarch64-unknown-linux-gnu-gcc -O2 testcase.c 
during RTL pass: expand
testcase.c: In function 'foo':
testcase.c:4:10: internal compiler error: in operand_subword_force, at
emit-rtl.cc:1824
    4 |   return __builtin_stdc_has_single_bit(b);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x25e580e internal_error(char const*, ...)
        /repo/gcc-trunk/gcc/diagnostic-global-context.cc:491
0xc38337 fancy_abort(char const*, int, char const*)
        /repo/gcc-trunk/gcc/diagnostic.cc:1772
0x7d8b86 operand_subword_force(rtx_def*, poly_int<2u, unsigned long>,
machine_mode)
        /repo/gcc-trunk/gcc/emit-rtl.cc:1824
0x1208289 expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*,
int, optab_methods)
        /repo/gcc-trunk/gcc/optabs.cc:1750
0xf12335 emit_store_flag_int(rtx_def*, rtx_def*, rtx_code, rtx_def*, rtx_def*,
scalar_int_mode, int, int, rtx_def*)
        /repo/gcc-trunk/gcc/expmed.cc:5851
0xf11f0e emit_store_flag(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode,
int, int)
        /repo/gcc-trunk/gcc/expmed.cc:6196
0x1066732 expand_POPCOUNT(internal_fn, gcall*)
        /repo/gcc-trunk/gcc/internal-fn.cc:5321
0x1066732 expand_POPCOUNT(internal_fn, gcall*)
        /repo/gcc-trunk/gcc/internal-fn.cc:5293
0xde58c7 expand_call_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:2801
0xde58c7 expand_gimple_stmt_1
        /repo/gcc-trunk/gcc/cfgexpand.cc:3962
0xde58c7 expand_gimple_stmt
        /repo/gcc-trunk/gcc/cfgexpand.cc:4104
0xdebf9e expand_gimple_basic_block
        /repo/gcc-trunk/gcc/cfgexpand.cc:6160
0xdeda66 execute
        /repo/gcc-trunk/gcc/cfgexpand.cc:6899
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.

$ aarch64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-aarch64/bin/aarch64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r15-3158-20240825101449-g91f549537ca-checking-yes-rtl-df-extra-aarch64/bin/../libexec/gcc/aarch64-unknown-linux-gnu/15.0.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl
--with-sysroot=/usr/aarch64-unknown-linux-gnu --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=aarch64-unknown-linux-gnu
--with-ld=/usr/bin/aarch64-unknown-linux-gnu-ld
--with-as=/usr/bin/aarch64-unknown-linux-gnu-as --enable-libsanitizer
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r15-3158-20240825101449-g91f549537ca-checking-yes-rtl-df-extra-aarch64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240825 (experimental) (GCC)

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
@ 2024-08-25 14:53 ` pinskia at gcc dot gnu.org
  2024-08-25 16:55 ` [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
          Component|rtl-optimization            |middle-end
   Target Milestone|---                         |15.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Maybe mine ...

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
  2024-08-25 14:53 ` [Bug middle-end/116480] " pinskia at gcc dot gnu.org
@ 2024-08-25 16:55 ` pinskia at gcc dot gnu.org
  2024-08-25 16:58 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-08-25
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
            Summary|[15 Regression] ICE: in     |[15 Regression] ICE: in
                   |operand_subword_force, at   |operand_subword_force, at
                   |emit-rtl.cc:1824 at -O2     |emit-rtl.cc:1824 at -O2
                   |with                        |with
                   |__builtin_stdc_has_single_b |__builtin_stdc_has_single_b
                   |it() and _BitInt() on       |it() and _BitInt(65...128)
                   |aarch64                     |on aarch64
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is definitely mine. Looks like something is not ready to support TImode
equals ...

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
  2024-08-25 14:53 ` [Bug middle-end/116480] " pinskia at gcc dot gnu.org
  2024-08-25 16:55 ` [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) " pinskia at gcc dot gnu.org
@ 2024-08-25 16:58 ` pinskia at gcc dot gnu.org
  2024-08-25 17:06 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 16:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Or rather the issue is here:
5320      rtx plhs = expand_normal (lhs);
5321      rtx pcmp = emit_store_flag (NULL_RTX, EQ, plhs, const1_rtx, mode, 0,
0);

We are expanding:
  int _1;
  uint128_t _2;
  _Bool _3;
  int _5;

  <bb 2> [local count: 1073741824]:
  _2 = (uint128_t) b_4(D);
  _1 = .POPCOUNT (_2, 1);


and then trying to use the wrong mode for the emit_store_flag here even though
the mode of plhs is SImode as the type of _1 (lhs) is int.

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-08-25 16:58 ` pinskia at gcc dot gnu.org
@ 2024-08-25 17:06 ` pinskia at gcc dot gnu.org
  2024-08-25 17:16 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Another testcase:
```
int
foo(unsigned __int128 b)
{
  return __builtin_popcountg(b) == 1;
}

```

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-08-25 17:06 ` pinskia at gcc dot gnu.org
@ 2024-08-25 17:16 ` pinskia at gcc dot gnu.org
  2024-08-25 20:34 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 58998
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58998&action=edit
patch which I am testing

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-08-25 17:16 ` pinskia at gcc dot gnu.org
@ 2024-08-25 20:34 ` pinskia at gcc dot gnu.org
  2024-08-26  9:35 ` cvs-commit at gcc dot gnu.org
  2024-08-26  9:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-25 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2024-August/
                   |                            |661414.html

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/661414.html

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-08-25 20:34 ` pinskia at gcc dot gnu.org
@ 2024-08-26  9:35 ` cvs-commit at gcc dot gnu.org
  2024-08-26  9:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-26  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:53b86cac7e77ddff4e8a215408f7331ebc5bf22c

commit r15-3187-g53b86cac7e77ddff4e8a215408f7331ebc5bf22c
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Sun Aug 25 10:10:06 2024 -0700

    expand: Use the correct mode for store flags for popcount [PR116480]

    When expanding popcount used for equal to 1 (or rather
__builtin_stdc_has_single_bit),
    the wrong mode was bsing used for the mode of the store flags. We were
using the mode
    of the argument to popcount but since popcount's return value is always
int, the mode
    of the expansion here should have been the mode of the return type rater
than the argument.

    Built and tested on aarch64-linux-gnu with no regressions.
    Also bootstrapped and tested on x86_64-linux-gnu.

            PR middle-end/116480

    gcc/ChangeLog:

            * internal-fn.cc (expand_POPCOUNT): Use the correct mode
            for store flags.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr116480-1.c: New test.
            * gcc.dg/torture/pr116480-2.c: New test.

    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

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

* [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) on aarch64
  2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2024-08-26  9:35 ` cvs-commit at gcc dot gnu.org
@ 2024-08-26  9:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-26  9:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2024-08-26  9:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-25 13:37 [Bug rtl-optimization/116480] New: [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt() on aarch64 zsojka at seznam dot cz
2024-08-25 14:53 ` [Bug middle-end/116480] " pinskia at gcc dot gnu.org
2024-08-25 16:55 ` [Bug middle-end/116480] [15 Regression] ICE: in operand_subword_force, at emit-rtl.cc:1824 at -O2 with __builtin_stdc_has_single_bit() and _BitInt(65...128) " pinskia at gcc dot gnu.org
2024-08-25 16:58 ` pinskia at gcc dot gnu.org
2024-08-25 17:06 ` pinskia at gcc dot gnu.org
2024-08-25 17:16 ` pinskia at gcc dot gnu.org
2024-08-25 20:34 ` pinskia at gcc dot gnu.org
2024-08-26  9:35 ` cvs-commit at gcc dot gnu.org
2024-08-26  9:36 ` 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).