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

            Bug ID: 129065
           Summary: [17 Regression] ICE in vectorizable_conversion, at
                    tree-vect-stmts.cc:5711 at -O3 (slp): narrowing
                    conversion of __builtin_popcount results
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi,

$cat repro.c

char a[64];
void g(int n) {
  for (int i = 0; i < n; i++) {
    a[22 + 2 * i] = __builtin_popcount(a[18 + 2 * i] + (unsigned)a[19 + 2 *
i]);
    a[23 + 2 * i] = __builtin_popcount(a[19 + 2 * i] + (unsigned)a[18 + 2 *
i]);
  }
}

$ gcc -O3 -c repro.c
during GIMPLE pass: slp
repro.c: In function 'g':
repro.c:2:6: internal compiler error: in vectorizable_conversion, at
tree-vect-stmts.cc:5711
    2 | void g(int n) {
      |      ^
0x2c4a51f internal_error(char const*, ...)
0xbb33bf fancy_abort(char const*, int, char const*)
0xa18384 vectorizable_conversion
        ../../gcc/tree-vect-stmts.cc:5711
0x172ee9d vect_analyze_stmt(vec_info*, _slp_tree*, _slp_instance*,
vec<stmt_info_for_cost, va_heap, vl_ptr>*)
        ../../gcc/tree-vect-stmts.cc:13250
0x179a1b9 vect_slp_analyze_node_operations_1
        ../../gcc/tree-vect-slp.cc:8959
0x179a1b9 vect_slp_analyze_node_operations
        ../../gcc/tree-vect-slp.cc:9249


Reproduced in Godbolt (gcc trunk, -O3 -c): https://godbolt.org/z/xqdWaETa5

## Checked versions
- gcc trunk 4eca40b54dd (2026-11-25, --enable-checking=yes): ICE at -O3
- Godbolt gcc trunk: ICE at -O3 (line 5705 there)
- gcc 16.2 with assertions (Godbolt), 16.0.1 20260315 and 15.2.0 (local):
compile it
- clang 21: compiles it

Thanks.

Reply via email to