2011/5/20 Richard Guenther <richard.guent...@gmail.com>: > On Thu, May 19, 2011 at 7:52 PM, Kai Tietz <ktiet...@googlemail.com> wrote: >> To illustrate in which scenario code in tree-ssa-forwprop doesn't help >> is binop-tor4.c >> >> w/o this patch we get >> >> >> foo (int a, int b, int c) >> { >> int e; >> int d; >> int D.2701; >> _Bool D.2700; >> _Bool D.2699; >> _Bool D.2698; >> _Bool D.2697; >> _Bool D.2696; >> int D.2695; >> >> <bb 2>: >> D.2695_3 = b_2(D) | a_1(D); >> d_4 = D.2695_3 != 0; >> D.2696_5 = a_1(D) == 0; >> D.2697_6 = b_2(D) == 0; >> D.2698_7 = D.2697_6 | D.2696_5; >> D.2699_9 = c_8(D) != 0; >> D.2700_10 = D.2698_7 | D.2699_9; >> e_11 = (int) D.2700_10; >> D.2701_12 = e_11 | d_4; >> return D.2701_12; >> } >> >> Of interest is here D.2701_12, which doesn't have a type sinking. >> This is caused by >> >> D.2695_3 = b_2(D) | a_1(D); >> d_4 = D.2695_3 != 0; >> >> which is a comparison result with implicit integer cast. So maybe the >> solution here could be to first doing boolification of comparison in >> gimplifier. By this, the code for type-sinking in my patch could go >> away. > > Well, forwprop either needs to be teached to handle this different kind > of widening > > d_4 = D.2687_3 != 0; > e_11 = (int) D.2692_10; > D.2694_12 = e_11 | d_4; > > or indeed comparisons should also be boolified (which I think they > should - they are also predicate producers). > > Still whether sinking or hoisting the stuff is the right thing, reassoc > is not the place to do it. > > Richard.
So I tested code to do boolifying of comparison in gimplifier. This works so far nice when fold_convert doesn't hoist for boolean-types. But in pass forwprop (see here function forward_propagate_comparison) does again type hoisting, which destroys of coures the boolified comparisons and so later reassociation pass has again the issue about finding matches. To introduce (as you suggested) into tree-ssa-forwprop the type sinking, therefore doesn't work. As type hoisting is for sure the better final result of an expression, but on expression folding passes it has advantages to use type sinking instead. So this might be a thing for a different pass, or in reassoc-pass itself (as patch does) as here type-sinking helps to combine. As after reassociation again the forward-propagation happens, we have still the better final expression variant as result. So how to continue here? Regards, Kai