[llvm] [ValueTracking] Implement udiv support for isKnownNonNullFromDominatingCondition (PR #67282)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 01:49:05 PDT 2023


================
@@ -2263,6 +2263,12 @@ static bool isKnownNonNullFromDominatingCondition(const Value *V,
         return true;
     }
 
+    if (const auto *Div = dyn_cast<BinaryOperator>(U);
+        Div && Div->getOpcode() == BinaryOperator::UDiv &&
+        Div->getOperand(1) == V &&
+        isValidAssumeForContext(cast<Instruction>(U), CtxI, DT))
----------------
nikic wrote:

isValidAssumeForContext() should be fine to use for non-assumes as well. The key property of assumes here is that violating the fact results in immediate undefined behavior, which is also true for divisions.

Though I guess the isEphemeralValueOf() part of the function is only relevant for assumes...

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


More information about the llvm-commits mailing list