mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[InstSimplify][NFC] Reorganize simplifyUnsignedRangeCheck() to emphasize and/or symmetry
Only a single `X >= Y && Y == 0 --> Y == 0` fold appears to be missing. llvm-svn: 372490
This commit is contained in:
parent
a95a2e0ed3
commit
fd7d7d4041
@ -1443,25 +1443,28 @@ static Value *simplifyUnsignedRangeCheck(ICmpInst *ZeroICmp,
|
||||
isKnownNonZero(X, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT))
|
||||
return IsAnd ? UnsignedICmp : ZeroICmp;
|
||||
|
||||
// X >= Y && Y == 0 --> Y == 0 FIXME
|
||||
// X >= Y || Y == 0 --> X >= Y
|
||||
if (UnsignedPred == ICmpInst::ICMP_UGE && EqPred == ICmpInst::ICMP_EQ &&
|
||||
!IsAnd)
|
||||
return UnsignedICmp;
|
||||
|
||||
// X > Y && Y == 0 --> Y == 0 iff X != 0
|
||||
// X > Y || Y == 0 --> X > Y iff X != 0
|
||||
if (UnsignedPred == ICmpInst::ICMP_UGT && EqPred == ICmpInst::ICMP_EQ &&
|
||||
isKnownNonZero(X, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT))
|
||||
return IsAnd ? ZeroICmp : UnsignedICmp;
|
||||
|
||||
// X >= Y || Y != 0 --> true
|
||||
// X >= Y || Y == 0 --> X >= Y
|
||||
if (UnsignedPred == ICmpInst::ICMP_UGE && !IsAnd) {
|
||||
if (EqPred == ICmpInst::ICMP_NE)
|
||||
return getTrue(UnsignedICmp->getType());
|
||||
return UnsignedICmp;
|
||||
}
|
||||
|
||||
// X < Y && Y == 0 --> false
|
||||
if (UnsignedPred == ICmpInst::ICMP_ULT && EqPred == ICmpInst::ICMP_EQ &&
|
||||
IsAnd)
|
||||
return getFalse(UnsignedICmp->getType());
|
||||
|
||||
// X >= Y || Y != 0 --> true
|
||||
if (UnsignedPred == ICmpInst::ICMP_UGE && EqPred == ICmpInst::ICMP_NE &&
|
||||
!IsAnd)
|
||||
return getTrue(UnsignedICmp->getType());
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user