https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104595
--- Comment #8 from Kewen Lin <linkw at gcc dot gnu.org> --- I had one local hack and just found it can survive on x86 bootstrapping and regression testing. I guess maybe it's good to post here. Just ignore this if it looks like noise. :) The point is to do the conversion for the loaded bool value from memory, normally it should be like a nop, but for this test case, it can help us to generate the expected char comparison. diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 2baf974627e..d4b8920203b 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -3911,6 +3911,11 @@ check_bool_pattern (tree var, vec_info *vinfo, hash_set<gimple *> &stmts) return false; break; + case ARRAY_REF: + if (TYPE_PRECISION (TREE_TYPE (var)) != 1) + return false; + break; + default: if (TREE_CODE_CLASS (rhs_code) == tcc_comparison) { @@ -4005,6 +4010,19 @@ adjust_bool_pattern (vec_info *vinfo, tree var, tree out_type, SSA_NAME, irhs1); break; + case ARRAY_REF: + { + itype = TREE_TYPE (var); + gcc_assert (TYPE_PRECISION (itype) == 1); + machine_mode mode = TYPE_MODE (itype); + tree scalar_type = build_nonstandard_integer_type ( + GET_MODE_BITSIZE (mode).to_constant (), TYPE_UNSIGNED (itype)); + pattern_stmt + = gimple_build_assign (vect_recog_temp_ssa_var (scalar_type, NULL), + CONVERT_EXPR, var); + } + break; + case BIT_NOT_EXPR: irhs1 = *defs.get (rhs1); itype = TREE_TYPE (irhs1);