> On Mar 5, 2019, at 8:44 AM, Richard Biener <richard.guent...@gmail.com> wrote: > >>>> >>>> >>>> will you commit this fix to gcc9 and gcc8 (we need it in gcc8)? >>> >>> I'll see to carve out some cycles trying to find a testcase and amend >>> the fix a bit >>> and will take care of testing/submitting the fix. Thanks for testing >>> that it works >>> for your case. >> >> I filed PR89595 with a testcase. > > So fixing it properly with also re-optimize_stmt those stmts so we'd CSE > the MAX_EXPR introduced by folding makes it somewhat ugly.
I tried the new patch on my side,Now, in the dump file of dom3: ======== Visiting statement: i_49 = _98 > 0 ? k_105 : 0; Meeting [0, 65535] and [0, 0] to [0, 65535] Intersecting [0, 65535] and [0, 65535] to [0, 65535] Optimizing statement i_49 = _98 > 0 ? k_105 : 0; Replaced 'k_105' with variable '_98' gimple_simplified to _152 = MAX_EXPR <_98, 0>; i_49 = _152; Folded to: i_49 = _152; LKUP STMT i_49 = _152 ==== ASGN i_49 = _152 Visiting statement: _152 = MAX_EXPR <_98, 0>; Optimizing statement _152 = MAX_EXPR <_98, 0>; LKUP STMT _152 = _98 max_expr 0 2>>> STMT _152 = _98 max_expr 0 ======== thanks. Qing > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. > > Any ideas how to make it less so? I can split out making optimize_stmt > take a gsi * btw, in case that's a more obvious change and it makes the > patch a little smaller. > > Richard. > > 2019-03-05 Richard Biener <rguent...@suse.de> > > PR tree-optimization/89595 > * tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Take > stmt iterator as reference, take boolean output parameter to > indicate whether the stmt was removed and thus the iterator > already advanced. > (dom_opt_dom_walker::before_dom_children): Re-iterate over > stmts created by folding. > > * gcc.dg/torture/pr89595.c: New testcase. > <fix-pr89595>