]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH v3] match.pd: (A>>bool) == 0 -> (unsigned)A) <= bool [PR119420]
authorJeff Law <jeffrey.law@oss.qualcomm.com>
Fri, 1 May 2026 21:27:48 +0000 (15:27 -0600)
committerJeff Law <jeffrey.law@oss.qualcomm.com>
Fri, 1 May 2026 21:35:27 +0000 (15:35 -0600)
commit3d83dd50bc9aed347570e453dfa60f1a69ea4e5a
treeff8dc31f9718d7ade5350383fcfef082af3d502a
parentf6f33ca83cb6b84cc5d157103ac70c143011b176
[PATCH v3] match.pd: (A>>bool) == 0 -> (unsigned)A) <= bool [PR119420]

Also add its counterpart:

"(A>>bool) != 0 -> (unsigned)A) > bool"

Changes from v2:
- gate the pattern with "#if GIMPLE"
- use 'single_use' in the rshift result
- add the NE variant
link: https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712431.html
Bootstrap tested in x86, aarch64 and RISC-V.
Regression tested in x86 and aarch64.

PR tree-optimization/119420

gcc/ChangeLog

* match.pd(`(A>>bool) EQ 0 -> (unsigned)A LE bool`): New
pattern.

gcc/testsuite/ChangeLog

* gcc.dg/tree-ssa/pr119420.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr119420.c [new file with mode: 0644]