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

            Bug ID: 127335
           Summary: https://ethz.ch/content/dam/ethz/special-interest/infk
                    /ast-dam/documents/Theodoridis-ASPLOS22-DCE-Paper.pdf
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyuwoncho18 at gmail dot com
  Target Milestone: ---

### Reproducer

typedef unsigned __int128 u128;

u128 crc128 (u128 seed)
{
  u128 c = seed;
  for (int k = 0; k < 8; k++)
    {
      if (c & 1)
        c = (((u128) 0xedb88320edb88320ULL << 64) | 0x1234567890abcdefULL) ^ (c
>> 1);
      else
        c = c >> 1;
    }
  return c;
}

It was compiled with -O0/-O1, but crashed with -O2/-O3.

$ gcc -O3 -freport-bug repro.c
during GIMPLE pass: crc
<source>: In function 'u128 crc128(u128)':
<source>:3:6: internal compiler error: in tree_to_uhwi, at tree.h:5127
    3 | u128 crc128 (u128 seed)
      |      ^~~~~~
0x22a6498 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x229f78b internal_error(char const*, ...)
        ???:0
0x7f904e fancy_abort(char const*, int, char const*)
        ???:0
0x11385aa state::do_binary_operation(tree_node*, tree_node*, tree_node*, void
(state::*)(value*, value*, tree_node*))
        ???:0
0x2210b32
crc_symbolic_execution::execute_bb_gimple_statements(basic_block_def*,
auto_vec<edge_def*, 0ul>&)
        ???:0
0x2211a0a crc_symbolic_execution::execute_crc_loop(gphi*, gphi*, bool)
        ???:0
0x2211b17 crc_symbolic_execution::extract_polynomial(gphi*, gphi*, tree_node*,
bool)
        ???:0
0x1132dd6 crc_optimization::execute(function*)
        ???:0
/cefs/17/17a2c76db590a13a8a92c74c_consolidated/compilers_c++_x86_gcc_16.2.0/bin/../libexec/gcc/x86_64-linux-gnu/16.2.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/17/17a2c76db590a13a8a92c74c_consolidated/compilers_c++_x86_gcc_16.2.0/bin/../lib/gcc/x86_64-linux-gnu/16.2.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -O3 -fdiagnostics-color=always
-fno-verbose-asm -freport-bug -o /app/output.s
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/cczvbLOn.out file, please attach this to
your bugreport.
Compiler returned: 1

Reproduced on gcc 15.1 ~ trunk

Reply via email to