summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r--lib/Analysis/ValueTracking.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index a5dceb6c2271..c0181662fd9d 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -17,9 +17,9 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/InstructionSimplify.h"
-#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/CallSite.h"
@@ -1982,7 +1982,7 @@ static bool isAddOfNonZero(const Value *V1, const Value *V2, const Query &Q) {
/// Return true if it is known that V1 != V2.
static bool isKnownNonEqual(const Value *V1, const Value *V2, const Query &Q) {
- if (V1->getType()->isVectorTy() || V1 == V2)
+ if (V1 == V2)
return false;
if (V1->getType() != V2->getType())
// We can't look through casts yet.
@@ -1990,18 +1990,14 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2, const Query &Q) {
if (isAddOfNonZero(V1, V2, Q) || isAddOfNonZero(V2, V1, Q))
return true;
- if (IntegerType *Ty = dyn_cast<IntegerType>(V1->getType())) {
+ if (V1->getType()->isIntOrIntVectorTy()) {
// Are any known bits in V1 contradictory to known bits in V2? If V1
// has a known zero where V2 has a known one, they must not be equal.
- auto BitWidth = Ty->getBitWidth();
- KnownBits Known1(BitWidth);
- computeKnownBits(V1, Known1, 0, Q);
- KnownBits Known2(BitWidth);
- computeKnownBits(V2, Known2, 0, Q);
-
- APInt OppositeBits = (Known1.Zero & Known2.One) |
- (Known2.Zero & Known1.One);
- if (OppositeBits.getBoolValue())
+ KnownBits Known1 = computeKnownBits(V1, 0, Q);
+ KnownBits Known2 = computeKnownBits(V2, 0, Q);
+
+ if (Known1.Zero.intersects(Known2.One) ||
+ Known2.Zero.intersects(Known1.One))
return true;
}
return false;
@@ -3082,7 +3078,7 @@ bool llvm::getConstantStringInfo(const Value *V, StringRef &Str,
Str = StringRef("", 1);
return true;
}
- // We cannot instantiate a StringRef as we do not have an apropriate string
+ // We cannot instantiate a StringRef as we do not have an appropriate string
// of 0s at hand.
return false;
}