https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122733
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:9785d99e281d829b1b97110859ee3b73dffa3b51 commit r16-5684-g9785d99e281d829b1b97110859ee3b73dffa3b51 Author: Jakub Jelinek <[email protected]> Date: Fri Nov 28 10:04:53 2025 +0100 match.pd: Re-add (y << x) {<,<=,>,>=} x simplifications [PR122733] Here is my attempt to implement what has been reverted in r16-5648 using ranger. Note also the changes to the equality pattern, first of all, there could be e.g. vector << scalar shifts, although they'll likely fail on the nop_convert vs. nop_convert, but also it would never match for say unsigned long long @0 and unsigned int @1 etc., pretty common cases. The new simplifier asks the ranger about ranges and bitmasks, verifies @0 is non-zero and that clz of the @0 nonzero bits bitmask (i.e. the minimum clz of all possible values of @0) is greater than (or greater than or equal to) maximum shift count. Which one of those depends on if the actual non-equality comparison is signed or unsigned. And gimple_match_range_of_expr now includes in itself undefined_p check and returns false even for that, so that many of the callers don't need to check that. 2025-11-28 Jakub Jelinek <[email protected]> PR tree-optimization/122733 * gimple-match-head.cc (gimple_match_range_of_expr): Return false even when range_of_expr returns true, but the range is undefined_p. * match.pd ((mult (plus:s@5 (mult:s@4 @0 @1) @2) @3)): Remove vr0.undefined_p () check. ((plus (mult:s@5 (plus:s@4 @0 @1) @2) @3)): Likewise. ((X + M*N) / N -> X / N + M): Remove vr4.undefined_p () check. ((X - M*N) / N -> X / N - M): Likewise. ((y << x) == x, (y << x) != x): Use convert2? instead of nop_convert2? and test INTEGRAL_TYPE_P on TREE_TYPE (@0) rather than TREE_TYPE (@1). ((y << x) {<,<=,>,>=} x): New simplification. (((T)(A)) + CST -> (T)(A + CST)): Remove vr.undefined_p () check. (x_5 == cstN ? cst4 : cst3): Remove r.undefined_p () check. * gcc.dg/match-shift-cmp-4.c: New test. * gcc.dg/match-shift-cmp-5.c: New test.
