Re: [PATCH] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-02 Thread Arjun Shankar via Gcc-patches
Hi Richard, > Oh, I see - that's very special then and the pattern in the comment > does not include this conversion. I think you can simplify the checking > done by requiring types_match (TREE_TYPE (@1), TREE_TYPE (@3)) > and by noting that the types of @0, @2 and @4 are the same > (you don't se

Re: [PATCH] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-02 Thread Richard Biener via Gcc-patches
On Tue, Feb 1, 2022 at 4:21 PM Arjun Shankar wrote: > > > +/* As a special case, X + C < Y + C is the same as X < Y even with wrapping > > + overflow if X and Y are signed integers of the same size, and C is an > > + unsigned constant with all bits except MSB set to 0 and size >= that of > > +

Re: [PATCH] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-01 Thread Arjun Shankar via Gcc-patches
> +/* As a special case, X + C < Y + C is the same as X < Y even with wrapping > + overflow if X and Y are signed integers of the same size, and C is an > + unsigned constant with all bits except MSB set to 0 and size >= that of > + X/Y. */ > +(for op (lt le ge gt) > + (simplify > + (op (pl

Re: [PATCH] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-01-31 Thread Richard Biener via Gcc-patches
On Tue, Feb 1, 2022 at 5:54 AM Arjun Shankar via Gcc-patches wrote: > > Expressions of the form "X + CST < Y + CST" where X and Y are of int > type and CST is of unsigned type with only the MSB on can be simplified > to "X < Y" because "X + 0x8000" increases monotonically with X. +/* As a spe

[PATCH] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-01-31 Thread Arjun Shankar via Gcc-patches
Expressions of the form "X + CST < Y + CST" where X and Y are of int type and CST is of unsigned type with only the MSB on can be simplified to "X < Y" because "X + 0x8000" increases monotonically with X. gcc/ * match.pd (X + C < Y + C -> X < Y, if C is 0x8000): New simplif