[llvm] [SelectionDAG] Add computeKnownBits support for ISD::STEP_VECTOR (PR #80452)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 11:44:38 PST 2024


================
@@ -3110,6 +3110,24 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
     }
     break;
   }
+  case ISD::STEP_VECTOR: {
+    const APInt &Step = Op.getConstantOperandAPInt(0);
+
+    if (Step.isPowerOf2())
+      Known.Zero.setLowBits(Step.logBase2());
+
+    const Function &F = getMachineFunction().getFunction();
+    bool Overflow;
+    const APInt MinNumElts =
+        APInt(BitWidth, Op.getValueType().getVectorMinNumElements());
+    const APInt MaxNumElts = getVScaleRange(&F, BitWidth)
+                                 .getUnsignedMax()
+                                 .umul_ov(MinNumElts, Overflow);
+    const APInt MaxValue = (MaxNumElts - 1).umul_ov(Step, Overflow);
----------------
topperc wrote:

The Overflow flag here doesn't have ORing sematnics does it? I assume the second call will clear if there is no overflow?

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


More information about the llvm-commits mailing list