[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.
GitOrigin-RevId: b63fc26d33e16698e015d5942b4065fbacf44909
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index 9578360..30b9c6e 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/lib/Analysis/InstructionSimplify.cpp
@@ -2421,23 +2421,19 @@
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());
}