[llvm] [AMDGPU] Support v_lshl_add_u64 with non-constant shift amount (PR #179904)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 03:54:44 PST 2026


================
@@ -638,19 +638,13 @@ class ThreeOpFrag<SDPatternOperator op1, SDPatternOperator op2> : ThreeOpFragSDA
 }
 
 def shl_0_to_4 : PatFrag<
-  (ops node:$src0, node:$src1), (shl node:$src0, node:$src1),
-  [{
-     if (auto *C = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
-       return C->getZExtValue() <= 4;
-     }
-     return false;
-   }]> {
+  (ops node:$src0, node:$src1), (shl node:$src0, node:$src1), [{
+    KnownBits KB = CurDAG->computeKnownBits(N->getOperand(1));
+    return KB.getMaxValue().getZExtValue() <= 4;
+  }]> {
   let GISelPredicateCode = [{
----------------
jayfoad wrote:

I think it would make sense to add globalisel RUN lines to the existing test.

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


More information about the llvm-commits mailing list