[PATCH] D12801: [ValueTracking] Add a new predicate: isKnownNonEqual()

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 02:03:39 PDT 2015


sanjoy added a comment.

Some minor comments inline.


================
Comment at: lib/Analysis/ValueTracking.cpp:1946
@@ -1934,1 +1945,3 @@
 
+/// Return true if V2 == V1 + X, where X is known non-zero.
+static bool isAddOfNonZero(Value *V1, Value *V2, const DataLayout &DL,
----------------
Isn't this checking `V1 == V2 + X`?  They're both equivalent though, so the answer is still okay, just mildly confusing. :)

================
Comment at: lib/Analysis/ValueTracking.cpp:1949
@@ +1948,3 @@
+                           const Query &Q) {
+  BinaryOperator *BO = dyn_cast<BinaryOperator>(V1);
+  if (!BO || BO->getOpcode() != Instruction::Add)
----------------
Why not use something from `PatternMatch.h` here, like `m_Add`?

================
Comment at: lib/Analysis/ValueTracking.cpp:1973
@@ +1972,3 @@
+
+  if (IntegerType *Ty = dyn_cast<IntegerType>(V1->getType())) {
+    // Are any known bits in V1 contradictory to known bits in V2? If V1
----------------
I'd use `auto *` here.

Also can this be relaxed to allow everything `computeKnownBits` can handle (i.e. allow pointers and vectors too)?


Repository:
  rL LLVM

http://reviews.llvm.org/D12801





More information about the llvm-commits mailing list