mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Simplify (A & ~B) in icmp if A is a power of 2
The transform will execute like so: (A & ~B) == 0 --> (A & B) != 0 (A & ~B) != 0 --> (A & B) == 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179386 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2669,6 +2669,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
||||
}
|
||||
|
||||
{ Value *A, *B;
|
||||
// Transform (A & ~B) == 0 --> (A & B) != 0
|
||||
// and (A & ~B) != 0 --> (A & B) == 0
|
||||
// if A is a power of 2.
|
||||
if (match(Op0, m_And(m_Value(A), m_Not(m_Value(B)))) &&
|
||||
match(Op1, m_Zero()) && isKnownToBeAPowerOfTwo(A) && I.isEquality())
|
||||
return new ICmpInst(I.getInversePredicate(),
|
||||
Builder->CreateAnd(A, B),
|
||||
Op1);
|
||||
|
||||
// ~x < ~y --> y < x
|
||||
// ~x < cst --> ~cst < x
|
||||
if (match(Op0, m_Not(m_Value(A)))) {
|
||||
|
Reference in New Issue
Block a user