On Thu, 18 Jun 2015, Jakub Jelinek wrote: > On Thu, May 21, 2015 at 05:28:14PM +0200, Jakub Jelinek wrote: > > For 4.9/4.8 a similar patch will be needed, but to > > fold-const.c/tree-ssa-forwprop.c instead of match.pd. > > Here is 4.9/4.8 backport of the patch. > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for 4.9/4.8?
Ok. Thanks, Richard. > 2015-06-18 Jakub Jelinek <ja...@redhat.com> > > PR tree-optimization/66233 > * fold-const.c (fold_unary_loc): Don't handle vector types. > Simplify. > * tree-ssa-forwprop.c (combine_conversions): Likewise. > > * gcc.c-torture/execute/pr66233.c: New test. > > --- gcc/fold-const.c.jj 2015-06-12 13:51:29.000000000 +0200 > +++ gcc/fold-const.c 2015-06-18 12:36:34.668565543 +0200 > @@ -8011,16 +8011,12 @@ fold_unary_loc (location_t loc, enum tre > (for integers). Avoid this if the final type is a pointer since > then we sometimes need the middle conversion. Likewise if the > final type has a precision not equal to the size of its mode. */ > - if (((inter_int && inside_int) > - || (inter_float && inside_float) > - || (inter_vec && inside_vec)) > + if (((inter_int && inside_int) || (inter_float && inside_float)) > + && (final_int || final_float) > && inter_prec >= inside_prec > - && (inter_float || inter_vec > - || inter_unsignedp == inside_unsignedp) > + && (inter_float || inter_unsignedp == inside_unsignedp) > && ! (final_prec != GET_MODE_PRECISION (TYPE_MODE (type)) > - && TYPE_MODE (type) == TYPE_MODE (inter_type)) > - && ! final_ptr > - && (! final_vec || inter_prec == inside_prec)) > + && TYPE_MODE (type) == TYPE_MODE (inter_type))) > return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0)); > > /* If we have a sign-extension of a zero-extended value, we can > --- gcc/tree-ssa-forwprop.c.jj 2014-12-13 09:42:36.000000000 +0100 > +++ gcc/tree-ssa-forwprop.c 2015-06-18 12:38:07.427149341 +0200 > @@ -3036,16 +3036,12 @@ combine_conversions (gimple_stmt_iterato > (for integers). Avoid this if the final type is a pointer since > then we sometimes need the middle conversion. Likewise if the > final type has a precision not equal to the size of its mode. */ > - if (((inter_int && inside_int) > - || (inter_float && inside_float) > - || (inter_vec && inside_vec)) > + if (((inter_int && inside_int) || (inter_float && inside_float)) > + && (final_int || final_float) > && inter_prec >= inside_prec > - && (inter_float || inter_vec > - || inter_unsignedp == inside_unsignedp) > + && (inter_float || inter_unsignedp == inside_unsignedp) > && ! (final_prec != GET_MODE_PRECISION (TYPE_MODE (type)) > - && TYPE_MODE (type) == TYPE_MODE (inter_type)) > - && ! final_ptr > - && (! final_vec || inter_prec == inside_prec)) > + && TYPE_MODE (type) == TYPE_MODE (inter_type))) > { > gimple_assign_set_rhs1 (stmt, defop0); > update_stmt (stmt); > --- gcc/testsuite/gcc.c-torture/execute/pr66233.c.jj 2015-06-18 > 12:39:01.600322247 +0200 > +++ gcc/testsuite/gcc.c-torture/execute/pr66233.c 2015-05-22 > 10:11:28.534792526 +0200 > @@ -0,0 +1,22 @@ > +/* PR tree-optimization/66233 */ > + > +unsigned int v[8]; > + > +__attribute__((noinline, noclone)) void > +foo (void) > +{ > + int i; > + for (i = 0; i < 8; i++) > + v[i] = (float) i; > +} > + > +int > +main () > +{ > + unsigned int i; > + foo (); > + for (i = 0; i < 8; i++) > + if (v[i] != i) > + __builtin_abort (); > + return 0; > +} > > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)