This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Fri, 14 Mar 2014, Prathamesh Kulkarni wrote:
On Fri, Mar 14, 2014 at 9:25 PM, Marc Glisse <marc.glisse@inria.fr> wrote:On Fri, 14 Mar 2014, Prathamesh Kulkarni wrote: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 << CST1That'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
Looks better. Though there is still the case where the new constant overflows, in which case we can fold the comparison to false.
b) (X & ~CST) == 0 -> X <= CSTUh, 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) ?
Wrong parentheses. And I didn't really think about it, so that may not be the right test.
I think it would be a good idea to write, in comments, next to each non-trivial transformation, a short "proof" (at least some form of explanation). It would help people re-reading it later see quickly why the conditions are what they are.
-- Marc Glisse
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |