[llvm] 417d695 - [InstSimplify] Reorder checks to be more efficient; NFC
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 20 14:05:52 PDT 2020
Author: Nikita Popov
Date: 2020-03-20T22:05:38+01:00
New Revision: 417d69595f0c338bc7e3a8b2b990c3d5f8c04249
URL: https://github.com/llvm/llvm-project/commit/417d69595f0c338bc7e3a8b2b990c3d5f8c04249
DIFF: https://github.com/llvm/llvm-project/commit/417d69595f0c338bc7e3a8b2b990c3d5f8c04249.diff
LOG: [InstSimplify] Reorder checks to be more efficient; NFC
First check whether the RHS is a null pointer, and only then
perform a potentially expensive non-zero query.
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 1e4d7f711785..ba1f55048700 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2340,10 +2340,9 @@ computePointerICmp(const DataLayout &DL, const TargetLibraryInfo *TLI,
RHS = RHS->stripPointerCasts();
// A non-null pointer is not equal to a null pointer.
- if (llvm::isKnownNonZero(LHS, DL, 0, nullptr, nullptr, nullptr,
- IIQ.UseInstrInfo) &&
- isa<ConstantPointerNull>(RHS) &&
- (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE))
+ if (isa<ConstantPointerNull>(RHS) && ICmpInst::isEquality(Pred) &&
+ llvm::isKnownNonZero(LHS, DL, 0, nullptr, nullptr, nullptr,
+ IIQ.UseInstrInfo))
return ConstantInt::get(GetCompareTy(LHS),
!CmpInst::isTrueWhenEqual(Pred));
More information about the llvm-commits
mailing list