https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116510
--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> --- On Tue, 15 Oct 2024, ak at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116510 > > --- Comment #12 from ak at gcc dot gnu.org --- > Like this? It fixes the test case. Yes, this looks good (maybe split the expressions to avoid long lines). > I'm not sure why you want AND_EXPR, this is a truth formula. Maybe it should > be > TRUTH_ANDIF_EXPR though to short circuit. On gimple it will be BIT_AND in the end, and TRUTH_ANDIF is simplified to TRUTH_AND if there's no side-effects. It doesn't matter in the end, but if-conversion somewhat relies on unfolded concat of conditions for its internal predicate handling so don't change any of that. > diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc > index 90c754a48147..376a4642954d 100644 > --- a/gcc/tree-if-conv.cc > +++ b/gcc/tree-if-conv.cc > @@ -1477,10 +1477,12 @@ predicate_bbs (loop_p loop) > { > tree low = build2_loc (loc, GE_EXPR, > boolean_type_node, > - index, CASE_LOW (label)); > + index, fold_convert_loc (loc, > TREE_TYPE (index), > + CASE_LOW (label))); > tree high = build2_loc (loc, LE_EXPR, > boolean_type_node, > - index, CASE_HIGH (label)); > + index, fold_convert_loc (loc, > TREE_TYPE (index), > + CASE_HIGH (label))); > case_cond = build2_loc (loc, TRUTH_AND_EXPR, > boolean_type_node, > low, high); > @@ -1489,7 +1491,8 @@ predicate_bbs (loop_p loop) > case_cond = build2_loc (loc, EQ_EXPR, > boolean_type_node, > index, > - CASE_LOW (gimple_switch_label (sw, > i))); > + fold_convert_loc (loc, TREE_TYPE > (index), > + CASE_LOW (label))); > if (i > 1) > switch_cond = build2_loc (loc, TRUTH_OR_EXPR, > boolean_type_node,