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

2022-06-20 Thread Arjun Shankar via Gcc-patches
Expressions of the form "X + CST < Y + CST" where: * CST is an unsigned integer constant with only the MSB set, and * X and Y's types have integer conversion ranks <= CST's can be simplified to "(signed) X < (signed) Y". This is because, assuming a 32-bit signed numbers, (unsigned) INT_MIN + 0x8

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

2022-06-17 Thread Arjun Shankar via Gcc-patches
Expressions of the form "X + CST < Y + CST" where: * CST is an unsigned integer constant with only the MSB set, and * X and Y's types have integer conversion ranks <= CST's can be simplified to "(signed) X < (signed) Y". This is because, assuming a 32-bit signed numbers, (unsigned) INT_MIN + 0x8

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

2022-02-02 Thread Arjun Shankar via Gcc-patches
Expressions of the form "X + CST < Y + CST" where: * CST is an unsigned integer constant with only the MSB set, and * X and Y's types have integer conversion ranks <= CST's can be simplified to "(signed) X < (signed) Y". This is because, assuming a 32-bit signed numbers, (unsigned) INT_MIN + 0x8

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-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

[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