From b63fc26d33e16698e015d5942b4065fbacf44909 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 5 Aug 2022 11:51:59 -0400 Subject: [PATCH] [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. --- llvm/lib/Analysis/InstructionSimplify.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 9578360..30b9c6e 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 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 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 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 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()); } -- 2.7.4