[llvm-branch-commits] [llvm] [AMDGPU] Lower uniform uaddsat.i16 to SALU instructions (PR #210156)

Anshil Gandhi via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 27 13:54:01 PDT 2026


================
@@ -8992,7 +8994,12 @@ SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
   SDValue NewVal;
   if (Opc == ISD::SELECT)
     NewVal = DAG.getNode(ISD::SELECT, DL, ExtTy, {Op->getOperand(0), LHS, RHS});
-  else
+  else if (Opc == ISD::UADDSAT) {
+    SDValue Sum = DAG.getNode(ISD::ADD, DL, ExtTy, LHS, RHS);
+    SDValue MaxVal = DAG.getConstant(
+        APInt::getMaxValue(OpTy.getScalarSizeInBits()).zext(32), DL, ExtTy);
+    NewVal = DAG.getNode(ISD::UMIN, DL, ExtTy, Sum, MaxVal);
----------------
gandhi56 wrote:

I could create a follow-up PR to implement a helper function to deduplicate the current instances.

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


More information about the llvm-branch-commits mailing list