aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-09-12 18:24:22 -0700
committerAndrew Pinski <pinskia@gmail.com>2023-10-27 00:49:30 -0700
commita5e69e94591ae282857d59e868ff6cea7306c802 (patch)
tree14ce48bb0a1eeed23e5f131ce19c7099595e08d9 /gcc/expr.cc
parent7eed861e8ca3f533e56dea6348573caa09f16f5e (diff)
downloadgcc-a5e69e94591ae282857d59e868ff6cea7306c802.zip
gcc-a5e69e94591ae282857d59e868ff6cea7306c802.tar.gz
gcc-a5e69e94591ae282857d59e868ff6cea7306c802.tar.bz2
MATCH: Simplify `(X &| B) CMP X` if possible [PR 101590]
I noticed we were missing these simplifications so let's add them. This adds the following simplifications: U & N <= U -> true U & N > U -> false When U is known to be as non-negative. When N is also known to be non-negative, this is also true: U | N < U -> false U | N >= U -> true When N is a negative integer, the result flips and we get: U | N < U -> true U | N >= U -> false We could extend this later on to be the case where we know N is nonconstant but is known to be negative. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/101590 PR tree-optimization/94884 gcc/ChangeLog: * match.pd (`(X BIT_OP Y) CMP X`): New pattern. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bitcmp-1.c: New test. * gcc.dg/tree-ssa/bitcmp-2.c: New test. * gcc.dg/tree-ssa/bitcmp-3.c: New test. * gcc.dg/tree-ssa/bitcmp-4.c: New test. * gcc.dg/tree-ssa/bitcmp-5.c: New test. * gcc.dg/tree-ssa/bitcmp-6.c: New test.
Diffstat (limited to 'gcc/expr.cc')
0 files changed, 0 insertions, 0 deletions