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

--- Comment #2 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
If the original example is not very nice `gcc` also ICEs on `llvm-src-21.1.2`.
Extracted example:

// $ cat LEB128Test.cpp.cpp
extern "C" unsigned long strlen(const char *);
inline long decodeSLEB128(unsigned char *p, unsigned char *end) {
  long Value = 0;
  unsigned Shift = 0, Byte;
  do {
    if (__builtin_expect(p == end, false))
      return 0;
    Byte = *p;
    unsigned long Slice = Byte & 5;
    Value |= Slice << Shift;
    Shift += 7;
    ++p;
  } while (Byte);
  Value |= 4073709551615UL << 7;
  return Value;
}
void Compare(const char *, const char *, long, long);
unsigned char LEB128Test_DecodeInvalidSLEB128_TestTestBody_Value;
void LEB128Test_DecodeInvalidSLEB128_TestTestBody() {
  long __trans_tmp_1 = strlen("\x80"),
       Actual = decodeSLEB128(
           &LEB128Test_DecodeInvalidSLEB128_TestTestBody_Value,
           &LEB128Test_DecodeInvalidSLEB128_TestTestBody_Value +
__trans_tmp_1);
  Compare("", "", 0, Actual);
}

gcc/xg++ -Bgcc -O2 -c LEB128Test.cpp.cpp -o bug.o -Wall
during GIMPLE pass: vect
LEB128Test.cpp.cpp: In function ‘void
LEB128Test_DecodeInvalidSLEB128_TestTestBody()’:
LEB128Test.cpp.cpp:19:6: internal compiler error: in
vect_analyze_slp_reduc_chain, at tree-vect-slp.cc:4215
   19 | void LEB128Test_DecodeInvalidSLEB128_TestTestBody() {
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x29601c4 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x295248c internal_error(char const*, ...)
        ???:0
0x295cff0 fancy_abort(char const*, int, char const*)
        ???:0
0x1759f9d vect_analyze_slp_reduc_chain(_loop_vec_info*,
hash_map<vec<_stmt_vec_info*, va_heap, vl_ptr>, _slp_tree*,
simple_hashmap_traits<bst_traits, _slp_tree*> >*, _stmt_vec_info*, unsigned
int, unsigned int*)
        ???:0
0x175adfe vect_analyze_slp_reduction(_loop_vec_info*, _stmt_vec_info*, unsigned
int, unsigned int*, hash_map<vec<_stmt_vec_info*, va_heap, vl_ptr>, _slp_tree*,
simple_hashmap_traits<bst_traits, _slp_tree*> >*, bool)
        ???:0
0x175fc53 vect_analyze_slp(vec_info*, unsigned int, bool)
        ???:0
0x171cf7c vect_analyze_loop_2(_loop_vec_info*, bool&, unsigned int*, bool&)
        ???:0
0x171d374 vect_analyze_loop_1(loop*, vec_info_shared*, vect_loop_form_info
const*, _loop_vec_info*, vec<machine_mode, va_heap, vl_ptr> const&, unsigned
int&, int, machine_mode&, bool&)
        ???:0
0x171dc57 vect_analyze_loop(loop*, gimple*, vec_info_shared*)
        ???:0
0x177e754 try_vectorize_loop(hash_table<simduid_to_vf, false, xcallocator>*&,
unsigned int*, loop*, function*)
        ???:0
0x177ed6d (anonymous namespace)::pass_vectorize::execute(function*)
        ???:0

Reply via email to