]> git.ipfire.org Git - thirdparty/gcc.git/commit
match.pd: Fold (y << x) <rel op> x -> 0 or 1
authorDhruv Chawla <dhruvc@nvidia.com>
Thu, 21 Aug 2025 09:06:07 +0000 (02:06 -0700)
committerDhruv Chawla <dhruvc@nvidia.com>
Tue, 11 Nov 2025 08:46:32 +0000 (14:16 +0530)
commitc4ca512358be7cb1c8523f148fa84a57cbbf0060
treeccec45f2fbdef56aa3cc15a13d1aa675a0908e63
parent8c34993da569afcf313594142eb44357a3ac239f
match.pd: Fold (y << x) <rel op> x -> 0 or 1

- (y << x) == x -> 0 when y != 0
- (y << x) {<,<=} x -> 0 when y > 0.
- (y << x) != x -> 1 when y != 0.
- (y << x) {>,>=} x -> 1 when y > 0.

Bootstrapped and regtested on aarch64-linux-gnu.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* match.pd: New patterns.

gcc/testsuite/ChangeLog:

* gcc.dg/match-shift-cmp-1.c: New test.
* gcc.dg/match-shift-cmp-2.c: Likewise.
* gcc.dg/match-shift-cmp-3.c: Likewise.
* gcc.dg/match-shift-cmp-4.c: Likewise.
gcc/match.pd
gcc/testsuite/gcc.dg/match-shift-cmp-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/match-shift-cmp-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/match-shift-cmp-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/match-shift-cmp-4.c [new file with mode: 0644]