Message ID | 20241015201804.1791191-1-ak@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | PR116510: Add missing fold_converts into tree switch if conversion | expand |
On Tue, Oct 15, 2024 at 10:18 PM Andi Kleen <ak@linux.intel.com> wrote: > > From: Andi Kleen <ak@gcc.gnu.org> > > Passes test suite. Ok to commit? OK. Thanks, Richard. > gcc/ChangeLog: > > PR middle-end/116510 > * tree-if-conv.cc (predicate_bbs): Add missing fold_converts. > > gcc/testsuite/ChangeLog: > > * gcc.dg/vect/vect-switch-ifcvt-3.c: New test. > --- > gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c | 12 ++++++++++++ > gcc/tree-if-conv.cc | 9 ++++++--- > 2 files changed, 18 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c b/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c > new file mode 100644 > index 000000000000..41bc8a1cf129 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c > @@ -0,0 +1,12 @@ > +/* { dg-do compile } */ > +// PR116510 > + > +char excmap_def_0; > +int gg_strescape_i; > +void gg_strescape() { > + for (; gg_strescape_i; gg_strescape_i++) > + switch ((unsigned char)gg_strescape_i) > + case '\\': > + case '"': > + excmap_def_0 = 0; > +} > 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, > -- > 2.46.2 >
diff --git a/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c b/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c new file mode 100644 index 000000000000..41bc8a1cf129 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +// PR116510 + +char excmap_def_0; +int gg_strescape_i; +void gg_strescape() { + for (; gg_strescape_i; gg_strescape_i++) + switch ((unsigned char)gg_strescape_i) + case '\\': + case '"': + excmap_def_0 = 0; +} 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,
From: Andi Kleen <ak@gcc.gnu.org> Passes test suite. Ok to commit? gcc/ChangeLog: PR middle-end/116510 * tree-if-conv.cc (predicate_bbs): Add missing fold_converts. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-switch-ifcvt-3.c: New test. --- gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c | 12 ++++++++++++ gcc/tree-if-conv.cc | 9 ++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-switch-ifcvt-3.c