[llvm] [LVI] Learn value ranges from ctpop/ctlz/cttz results (PR #121945)

Stephen Senran Zhang via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 12 21:37:06 PST 2025


================
@@ -1191,6 +1257,13 @@ std::optional<ValueLatticeElement> LazyValueInfoImpl::getValueFromICmpCondition(
   if (matchICmpOperand(Offset, RHS, Val, SwappedPred))
     return getValueFromSimpleICmpCondition(SwappedPred, LHS, Offset, ICI,
                                            UseBlockValue);
+  Intrinsic::ID IID;
+  if (matchBitIntrinsic(LHS, Val, IID))
+    return getValueFromICmpBitIntrinsic(EdgePred, BitWidth, IID, RHS, ICI,
+                                        UseBlockValue);
+  if (matchBitIntrinsic(RHS, Val, IID))
+    return getValueFromICmpBitIntrinsic(SwappedPred, BitWidth, IID, LHS, ICI,
----------------
zsrkmyn wrote:

As nikic suggests only handling constant cases, and constants will be always placed at RHS by instcombine, I removed the commuted comparison handling.

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


More information about the llvm-commits mailing list