[Bug tree-optimization/110010] (a>>N) != (b>>N) is not optimized to (a^b) >= (1<<N)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 1 20:14:57 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110010
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <law@gcc.gnu.org>:
https://gcc.gnu.org/g:9c40f8de18908bd0e09dafd5e21895d285044e11
commit r17-263-g9c40f8de18908bd0e09dafd5e21895d285044e11
Author: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Date: Fri May 1 14:13:51 2026 -0600
[PATCH v3] match.pd: (A>>C) != (B>>C) -> (A^B) >= (1<<C) [PR110010]
Also adding the variant "(A>>C) == (B>>C) -> (A^B) < (1<<C)"
Bootstrapped on x86, aarch64 and rv64.
Regression tested on x86 and aarch64.
Changes from v2:
- add type_has_mode_precision_p () check
- add types_match() to simplify types comparison
- add rshift operand checks (must not be negative, must not
surpass type size)
- v2 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-March/711284.html
PR tree-optimization/110010
gcc/ChangeLog:
* match.pd (`(A>>C) NE|EQ (B>>C) -> (A^B) GE|LT (1<<C)`): New
pattern.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr110010.c: New test.
More information about the Gcc-bugs
mailing list