On Fri, Mar 14, 2014 at 9:25 PM, Marc Glisse <marc.gli...@inria.fr> wrote: > On Fri, 14 Mar 2014, Prathamesh Kulkarni wrote: > >> I had a look at PR 14753 >> (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14753) from the first >> link. I have tried to implement those transforms (attached patch, >> stage-1 compiled). >> I have written the transforms to operate on GENERIC. > > > Why not directly gimple or the .pd file? > > >> Is that correct ? >> The patterns mentioned in the links were: >> a) (X >> CST1) >= CST2 -> X >= CST2 << CST1 >> however, an expression Y >= CST gets folded to Y > CST - 1 >> so the transform I wrote: >> (X >> CST1) > CST2 -> X > CST2 << CST1 > > > That's not the same, try X=1, CST1=1, CST2=0. Ah yes. Shall following be correct ? (X >> CST1) > CST2 -> X > ( (CST2 + 1) << CST1 ) - 1 Works correctly for X=1, CST1 = 1, CST2 = 0
(X >> CST1) > CST2 => (X >> CST1) >= (CST2 + 1) // this pattern is mentioned in PR => X >= (CST2 + 1) << CST1 => X > ((CST2 + 1) << CST1) - 1 > > >> b) (X & ~CST) == 0 -> X <= CST > > > Uh, that can't be true for all constants, only some with a very specific > shape (7 is 2^3-1). Agreed. Shall the pattern be folded if CST is 2^(n-1) ? > > -- > Marc Glisse