[llvm] [DAG] Define computeConstantRange for VSCALE folding (PR #176027)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 12:50:17 PST 2026
================
@@ -4563,6 +4563,42 @@ SelectionDAG::computeOverflowForSignedMul(SDValue N0, SDValue N1) const {
return OFK_Sometime;
}
+ConstantRange SelectionDAG::computeConstantRange(SDValue Op,
+ const APInt &DemandedElts,
+ unsigned Depth) const {
+ EVT VT = Op.getValueType();
+ unsigned BitWidth = VT.getScalarSizeInBits();
+
+ if (Depth >= MaxRecursionDepth)
+ return ConstantRange::getFull(BitWidth);
+
+ if (ConstantSDNode *C = isConstOrConstSplat(Op, DemandedElts))
+ return ConstantRange(C->getAPIntValue());
+
+ unsigned Opcode = Op.getOpcode();
+ switch (Opcode) {
+ case ISD::VSCALE: {
+ const Function &F = getMachineFunction().getFunction();
+ const APInt &Multiplier = Op.getConstantOperandAPInt(0);
+ return getVScaleRange(&F, BitWidth).multiply(Multiplier);
+ }
+ default:
+ break;
+ }
+
+ return ConstantRange::getFull(BitWidth);
+}
+
+ConstantRange SelectionDAG::computeConstantRangeIncludingKnownBits(
----------------
topperc wrote:
So the test cases don't test this patch?
https://github.com/llvm/llvm-project/pull/176027
More information about the llvm-commits
mailing list