[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 00:15:07 PDT 2024


================
@@ -3520,6 +3520,33 @@ static bool matchFMulByZeroIfResultEqZero(InstCombinerImpl &IC, Value *Cmp0,
   return false;
 }
 
+/// Check whether the KnownBits of a select arm may be affected by the
+/// select condition.
+static bool hasAffectedValue(Value *V, SmallPtrSetImpl<Value *> &Affected,
+                             unsigned Depth) {
+  if (Depth == MaxAnalysisRecursionDepth)
+    return false;
+
+  // Ignore the case where the select arm itself is affected. These cases
+  // are handled more efficiently by other optimizations.
+  if (Affected.contains(V) && Depth != 0)
----------------
goldsteinn wrote:

These should probably be inverted (cheaper check on left).

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


More information about the llvm-commits mailing list