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

            Bug ID: 103544
           Summary: compiler crashes when trying to vectorize loop
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: monad at posteo dot net
  Target Milestone: ---

the following program crashes g++:


int crash_me(char* ptr, size_t size){
    std::array<short, 16> result = {0};

    size_t no_iters = 0;
    for(size_t i = 0; i < size - 12; i+= 13){
        for(size_t j = 0; j < 12; j++){
            result[j] += ptr[i + j] - '0';
        }
        no_iters++;
    }

    int result_int = 0;
    for(int j = 0; j < 12; j++){
        int bit_value = result[j] > no_iters/2 ? 1 : 0;
        result_int |= bit_value;
    }

    return result_int;
}




it results in:


during GIMPLE pass: vect
<source>: In function 'int crash_me(char*, size_t)':
<source>:4:5: internal compiler error: in vect_transform_reduction, at
tree-vect-loop.c:7378
    4 | int crash_me(char* ptr, size_t size){
      |     ^~~~~~~~
0x1786229 internal_error(char const*, ...)
        ???:0
0x678608 fancy_abort(char const*, int, char const*)
        ???:0
0xf53cdc vect_transform_reduction(_loop_vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, gimple**, _slp_tree*)
        ???:0
0xf4936d vect_transform_stmt(vec_info*, _stmt_vec_info*, gimple_stmt_iterator*,
_slp_tree*, _slp_instance*)
        ???:0
0xf861ee vect_schedule_slp(vec_info*, vec<_slp_instance*, va_heap, vl_ptr>)
        ???:0
0xf64ed0 vect_transform_loop(_loop_vec_info*, gimple*)
        ???:0
0xf90d61 vectorize_loops()
        ???:0





optimization flags used: -O3 -march=haswell
g++ version: 11.1 on my local machine, 11.2 on godbolt. 
godbolt link: https://godbolt.org/z/WjPbcE4sa

Reply via email to