aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2022-08-05 11:51:59 -0400
committerSanjay Patel <spatel@rotateright.com>2022-08-05 12:06:47 -0400
commitb63fc26d33e16698e015d5942b4065fbacf44909 (patch)
tree96fc22310d179ed359aee49a158522300e35d7a9
parent0533c39a765318404a1e50cfd5279410f4ebe2c8 (diff)
[InstSimplify] make uses of isImpliedCondition more efficient (NFCI)
As suggested in the post-commit comments for 019d76196f79fcff3c148, this makes the usage symmetric with the 'and' patterns and should be more efficient.
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 95783607a0b2..30b9c6e4ef9d 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2421,23 +2421,19 @@ static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
return V;
if (Op0->getType()->isIntOrIntVectorTy(1)) {
- // If Op0 is true implies Op1 is true, then Op0 is a subset of Op1.
- if (Optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL)) {
- if (*Implied == true)
- return Op1;
- }
- // If Op0 is false implies Op1 is true, then at least one is always true.
if (Optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL, false)) {
+ // If Op0 is false implies Op1 is false, then Op1 is a subset of Op0.
+ if (*Implied == false)
+ return Op0;
+ // If Op0 is false implies Op1 is true, then at least one is always true.
if (*Implied == true)
return ConstantInt::getTrue(Op0->getType());
}
- // If Op1 is true implies Op0 is true, then Op1 is a subset of Op0.
- if (Optional<bool> Implied = isImpliedCondition(Op1, Op0, Q.DL)) {
- if (*Implied == true)
- return Op0;
- }
- // If Op1 is false implies Op0 is true, then at least one is always true.
if (Optional<bool> Implied = isImpliedCondition(Op1, Op0, Q.DL, false)) {
+ // If Op1 is false implies Op0 is false, then Op0 is a subset of Op1.
+ if (*Implied == false)
+ return Op1;
+ // If Op1 is false implies Op0 is true, then at least one is always true.
if (*Implied == true)
return ConstantInt::getTrue(Op1->getType());
}