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

            Bug ID: 125209
           Summary: ICE on valid code at -O1 and above on
                    x86_64-linux-gnu: in simplify_subreg, at
                    simplify-rtx.cc:8365
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/aGvnnKjnf

Note:
- fails: 16.1 and trunk
- works: 15.2 and earlier

[516] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20260506 (experimental) (GCC) 
[517] % 
[517] % gcctk -c -O1 small.c
[518] % 
[518] % gcctk -c -O1 -fno-tree-sink small.c
during RTL pass: combine
small.c: In function ‘main’:
small.c:9:1: internal compiler error: in simplify_subreg, at
simplify-rtx.cc:8365
    9 | }
      | ^
0x26185fb internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:787
0xa253d0 fancy_abort(char const*, int, char const*)
        ../../gcc-trunk/gcc/diagnostics/context.cc:1813
0x8ac23a simplify_context::simplify_subreg(machine_mode, rtx_def*,
machine_mode, poly_int<1u, unsigned long>)
        ../../gcc-trunk/gcc/simplify-rtx.cc:8365
0x11bd141 operator()
        ../../gcc-trunk/gcc/simplify-rtx.cc:8619
0x11bd141 simplify_context::simplify_subreg(machine_mode, rtx_def*,
machine_mode, poly_int<1u, unsigned long>)
        ../../gcc-trunk/gcc/simplify-rtx.cc:8658
0x235a407 simplify_subreg(machine_mode, rtx_def*, machine_mode, poly_int<1u,
unsigned long>)
        ../../gcc-trunk/gcc/rtl.h:3582
0x235a407 make_compound_operation_int
        ../../gcc-trunk/gcc/combine.cc:8441
0x2359dcf make_compound_operation(rtx_def*, rtx_code)
        ../../gcc-trunk/gcc/combine.cc:8528
0x2359d94 make_compound_operation(rtx_def*, rtx_code)
        ../../gcc-trunk/gcc/combine.cc:8553
0x235a3dc make_compound_operation_int
        ../../gcc-trunk/gcc/combine.cc:8438
0x2359dcf make_compound_operation(rtx_def*, rtx_code)
        ../../gcc-trunk/gcc/combine.cc:8528
0x235cffc simplify_set
        ../../gcc-trunk/gcc/combine.cc:7032
0x2360bdf subst
        ../../gcc-trunk/gcc/combine.cc:5662
0x23647ee try_combine
        ../../gcc-trunk/gcc/combine.cc:3359
0x236ab89 combine_instructions
        ../../gcc-trunk/gcc/combine.cc:1293
0x236ab89 rest_of_handle_combine
        ../../gcc-trunk/gcc/combine.cc:15235
0x236ab89 execute
        ../../gcc-trunk/gcc/combine.cc:15279
/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1
-quiet -I /usr/local/include -I /local/suz-local/software/local/include
-imultiarch x86_64-linux-gnu -iprefix
/local/home/suz/suz-local/software/local/gcc-trunk/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/
small.c -quiet -dumpbase small.c -dumpbase-ext .c -mtune=generic -march=x86-64
-O1 -fno-tree-sink -o /tmp/ccj0FHZA.s
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.
[519] % 
[519] % cat small.c
int a, b;
volatile unsigned c;
extern void d(unsigned short);
int e(long f) { return a ? f : 0; }
int main() {
  int g = e(c ^ !b);
  d(g);
  return 0;
}

Reply via email to