[llvm] [DAG] Replace getValid*ShiftAmountConstant helpers with getValid*ShiftAmount helpers to support KnownBits analysis (PR #93182)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 12:21:31 PDT 2024


================
@@ -3020,91 +3020,111 @@ SelectionDAG::getValidShiftAmountConstant(SDValue V,
     // Shifting more than the bitwidth is not valid.
     const APInt &ShAmt = SA->getAPIntValue();
     if (ShAmt.ult(BitWidth))
-      return &ShAmt;
+      return ShAmt.getZExtValue();
+  } else {
+    KnownBits KnownAmt =
+        computeKnownBits(V.getOperand(1), DemandedElts, Depth + 1);
+    if (KnownAmt.isConstant() && KnownAmt.getConstant().ult(BitWidth))
----------------
goldsteinn wrote:

IMO if its constant only, Depth should start at MaxDepth - 2, otherwise think there is a lot of wasted compute.

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


More information about the llvm-commits mailing list