[llvm] [ValueTracking] Take into account whether zero is poison when computing CR for `ct{t,l}z` (PR #122548)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 11 10:52:30 PST 2025


================
@@ -9898,13 +9898,20 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
   }
 }
 
-static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
+static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II,
+                                          bool UseInstrInfo) {
   unsigned Width = II.getType()->getScalarSizeInBits();
   const APInt *C;
   switch (II.getIntrinsicID()) {
-  case Intrinsic::ctpop:
   case Intrinsic::ctlz:
-  case Intrinsic::cttz:
+  case Intrinsic::cttz: {
+    APInt Upper = APInt(Width, Width);
+    if (!UseInstrInfo || !match(II.getArgOperand(1), m_One()))
----------------
goldsteinn wrote:

Think attr would make more sense, its typically how we communicate poison generating constraints.

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


More information about the llvm-commits mailing list