[llvm] [ValueTracking] Analyze `Select` in `isKnownNonEqual`. (PR #68427)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 10:29:00 PDT 2023


================
@@ -3112,6 +3112,23 @@ static bool isNonEqualPHIs(const PHINode *PN1, const PHINode *PN2,
   return true;
 }
 
+static bool isNonEqualSELECT(const Value *V1, const Value *V2, unsigned Depth,
+                             const SimplifyQuery &Q) {
+  const SelectInst *SI1 = dyn_cast<SelectInst>(V1);
+  if (!SI1)
+    return false;
+
+  if (const SelectInst *SI2 = dyn_cast<SelectInst>(V2)) {
+    if (SI1->getCondition() == SI2->getCondition())
+      return isKnownNonEqual(SI1->getTrueValue(), SI2->getTrueValue(),
+                             Depth + 1, Q) &&
+             isKnownNonEqual(SI1->getFalseValue(), SI2->getFalseValue(),
+                             Depth + 1, Q);
+  }
----------------
goldsteinn wrote:

You could also check cond and ~cond case

https://github.com/llvm/llvm-project/pull/68427


More information about the llvm-commits mailing list