https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98914
--- Comment #1 from luoxhu at gcc dot gnu.org --- The type of k in the case should be "long" to reproduce the issue, ICE happens at rs6000_expand_vector_set: gcc_assert (GET_MODE (idx) == E_SImode); Reason is the vector index variable need be "signed int" for all vec_insert prototype. ELFv2 ABI: vector signed char vec_insert (signed char, vector signed char, signed int); vector unsigned char vec_insert (unsigned char, vector unsigned char, signed int); vector signed int vec_insert (signed int, vector signed int, signed int); vector unsigned int vec_insert (unsigned int, vector unsigned int, signed int); vector signed long long vec_insert (signed long long, vector signed long long, signed int); Not sure all targets like X86/AArch64 also has some requirements, and whether below fix reasonable to not generate IFN VEC_SET for stmt like VIEW_CONVERT_EXPR<unsigned char[16]>(v)[k_7] = 170; ? diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc index 2c78a08d3f1..dbbae270a36 100644 --- a/gcc/gimple-isel.cc +++ b/gcc/gimple-isel.cc @@ -77,6 +77,7 @@ gimple_expand_vec_set_expr (gimple_stmt_iterator *gsi) tree view_op0 = TREE_OPERAND (op0, 0); machine_mode outermode = TYPE_MODE (TREE_TYPE (view_op0)); if (auto_var_in_fn_p (view_op0, cfun->decl) + && TYPE_MODE (TREE_TYPE (pos)) == E_SImode && !TREE_ADDRESSABLE (view_op0) && can_vec_set_var_idx_p (outermode)) { location_t loc = gimple_location (stmt);