On 5/29/19 7:36 AM, Richard Biener wrote: > > The following tries to address PR90648 by performing final > value replacement from DCE when DCE knows the final value > computation is not used during loop iteration. This fits > neatly enough into existing tricks performed by DCE like > removing unused malloc/free pairs. DO you have the right BZ #? 90648 is a ICE in tree checking and doesn't have a loop :-)
> > There's a few complications, one is it fails to bootstrap > because it exposes a few uninit warning false positives, > another is that -fno-tree-sccp is no longer effective. > As written this turns gcc.dg/pr34027-1.c into a division > again (I did not copy the expression_expensive checking). > It seems to also need -ftrapv adjustements (gcc.dg/pr81661.c). > > The goal of this patch is to remove the SCCP pass, or rather > us unconditionally replacing loop-closed PHIs with final > value computations which we've got complaints in the past > already that it duplicates computation that is readily > available. I've not yet figured testsuite fallout from that > change. > > For the -fno-tree-sccp I consider to simply honor that > flag in the DCE path, for the gcc.dg/pr34027-1.c I'll > re-install the expression_expensive checking. I'll > also fix the -ftrapv issue. > > Does this otherwise look a sensible way forward? > > Thanks, > Richard. > > FAIL: gcc.dg/builtin-object-size-1.c execution test > FAIL: gcc.dg/builtin-object-size-5.c scan-assembler-not abort > FAIL: gcc.dg/pr34027-1.c scan-tree-dump-times optimized " / " 0 > FAIL: gcc.dg/pr81661.c (internal compiler error) > FAIL: gcc.dg/pr81661.c (test for excess errors) > XPASS: gcc.dg/tree-ssa/loop-15.c scan-tree-dump-times optimized " \\\\+ " 0 > FAIL: gcc.dg/tree-ssa/loop-15.c scan-tree-dump-times optimized "if " 1 > FAIL: gcc.dg/tree-ssa/loop-26.c scan-tree-dump-times optimized "if" 2 > FAIL: gcc.dg/tree-ssa/pr32044.c scan-tree-dump-times optimized " / " 0 > FAIL: gcc.dg/tree-ssa/pr32044.c scan-tree-dump-times optimized "if" 6 > FAIL: gcc.dg/tree-ssa/pr64183.c scan-tree-dump cunroll "Loop 2 iterates at > most 3 times" > FAIL: gcc.dg/tree-ssa/ssa-pre-3.c scan-tree-dump-times pre "Eliminated: 2" 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-3.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-5.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-11.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-13.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-14.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-15.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-16.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-17.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-18.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-19.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-2.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED" 1 > FAIL: gcc.dg/vect/no-scevccp-outer-20.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-21.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-3.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-5.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-6-global.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-6.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-7.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-8.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-1.c scan-tree-dump-times vect > "vectorized 1 loops" 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-3.c scan-tree-dump-times vect > "vect_recog_widen_sum_pattern: detected" 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-3.c scan-tree-dump-times vect > "vectorized 1 loops" 1 > > Running target unix//-m32 > FAIL: gcc.dg/builtin-object-size-1.c execution test > FAIL: gcc.dg/builtin-object-size-5.c scan-assembler-not abort > FAIL: gcc.dg/pr34027-1.c scan-tree-dump-times optimized " / " 0 > FAIL: gcc.dg/pr81661.c (internal compiler error) > FAIL: gcc.dg/pr81661.c (test for excess errors) > XPASS: gcc.dg/tree-ssa/loop-15.c scan-tree-dump-times optimized " \\\\+ " 0 > FAIL: gcc.dg/tree-ssa/loop-15.c scan-tree-dump-times optimized "if " 1 > FAIL: gcc.dg/tree-ssa/loop-26.c scan-tree-dump-times optimized "if" 2 > FAIL: gcc.dg/tree-ssa/pr32044.c scan-tree-dump-times optimized " / " 0 > FAIL: gcc.dg/tree-ssa/pr32044.c scan-tree-dump-times optimized "if" 6 > FAIL: gcc.dg/tree-ssa/pr64183.c scan-tree-dump cunroll "Loop 2 iterates at > most 3 times" > FAIL: gcc.dg/tree-ssa/ssa-pre-3.c scan-tree-dump-times pre "Eliminated: 2" 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-3.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-4.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-noreassoc-outer-5.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-11.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-13.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-14.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-15.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-16.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-17.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-18.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-19.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-2.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED" 1 > FAIL: gcc.dg/vect/no-scevccp-outer-20.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-21.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-3.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-5.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-6-global.c scan-tree-dump-times vect > "OUTER LOOP VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-6.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-7.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-outer-8.c scan-tree-dump-times vect "OUTER LOOP > VECTORIZED." 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-1.c scan-tree-dump-times vect > "vectorized 1 loops" 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-3.c scan-tree-dump-times vect > "vect_recog_widen_sum_pattern: detected" 1 > FAIL: gcc.dg/vect/no-scevccp-vect-iv-3.c scan-tree-dump-times vect > "vectorized 1 loops" 1 > FAIL: gcc.target/i386/pr85073.c scan-assembler-times test 1 > > 2019-05-29 Richard Biener <rguent...@suse.de> > > PR tree-optimization/90594 > * tree-scalar-evolution.h (final_value_replacement): Declare. > * tree-scalar-evolution.c (final_value_replacement): Split out > worker on one PHI from ... > (final_value_replacement_loop): ... here. > * gimple-fold.h (rewrite_seq_to_defined_overflow): Declare. > * gimple-fold.c (rewrite_seq_to_defined_overflow): Wrap > around rewrite_to_defined_overflow to handle a whole sequence. > * tree-ssa-dce.c (lcphi_map): New. > (mark_operands_necessary): New walk_tree worker. > (propagate_necessity): Elide defs of LC PHIs we can perform value > replacement on. > (remove_dead_phis): Perform value replacement on LC PHIs that > had their def removed. > (perform_tree_ssa_dce): Go into LC SSA in aggressive mode. > Precompute final value replacements. > > * gcc.dg/tree-ssa/loop-14.c: Adjust for new expected place > for transform. The approach here looks quite reasonable to me, so it's just a matter of the fallout, as are so many things these days... jeff