forked from OSchip/llvm-project
[InstCombine] foldAndOfICmps(): Acquire SimplifyQuery with set CxtI
Extracted from https://reviews.llvm.org/D67849#inline-610377 llvm-svn: 372653
This commit is contained in:
parent
948786c929
commit
595cfda059
|
@ -1111,6 +1111,8 @@ static Value *foldUnsignedUnderflowCheck(ICmpInst *ZeroICmp,
|
||||||
/// Fold (icmp)&(icmp) if possible.
|
/// Fold (icmp)&(icmp) if possible.
|
||||||
Value *InstCombiner::foldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS,
|
Value *InstCombiner::foldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS,
|
||||||
Instruction &CxtI) {
|
Instruction &CxtI) {
|
||||||
|
const SimplifyQuery Q = SQ.getWithInstruction(&CxtI);
|
||||||
|
|
||||||
// Fold (!iszero(A & K1) & !iszero(A & K2)) -> (A & (K1 | K2)) == (K1 | K2)
|
// Fold (!iszero(A & K1) & !iszero(A & K2)) -> (A & (K1 | K2)) == (K1 | K2)
|
||||||
// if K1 and K2 are a one-bit mask.
|
// if K1 and K2 are a one-bit mask.
|
||||||
if (Value *V = foldAndOrOfICmpsOfAndWithPow2(LHS, RHS, true, CxtI))
|
if (Value *V = foldAndOrOfICmpsOfAndWithPow2(LHS, RHS, true, CxtI))
|
||||||
|
@ -1154,10 +1156,10 @@ Value *InstCombiner::foldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS,
|
||||||
return V;
|
return V;
|
||||||
|
|
||||||
if (Value *X =
|
if (Value *X =
|
||||||
foldUnsignedUnderflowCheck(LHS, RHS, /*IsAnd=*/true, SQ, Builder))
|
foldUnsignedUnderflowCheck(LHS, RHS, /*IsAnd=*/true, Q, Builder))
|
||||||
return X;
|
return X;
|
||||||
if (Value *X =
|
if (Value *X =
|
||||||
foldUnsignedUnderflowCheck(RHS, LHS, /*IsAnd=*/true, SQ, Builder))
|
foldUnsignedUnderflowCheck(RHS, LHS, /*IsAnd=*/true, Q, Builder))
|
||||||
return X;
|
return X;
|
||||||
|
|
||||||
// This only handles icmp of constants: (icmp1 A, C1) & (icmp2 B, C2).
|
// This only handles icmp of constants: (icmp1 A, C1) & (icmp2 B, C2).
|
||||||
|
|
Loading…
Reference in New Issue