[llvm] [AMDGPU] Lower uniform usubsat to SOP (PR #203155)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 01:21:29 PDT 2026
================
@@ -2070,6 +2070,23 @@ let AddedComplexity = 20 in {
>;
}
+// Uniform saturating unsigned subtraction: usubsat(a, b) = max(a, b) - b
+// If a >= b, result is a - b; otherwise max(a, b) = b, so b - b = 0.
+// Higher complexity to prefer scalar over VALU patterns for uniform values.
+let AddedComplexity = 20 in {
+ def : GCNPat<
+ (i32 (UniformBinFrag<usubsat> i32:$src0, i32:$src1)),
+ (S_SUB_I32 (S_MAX_U32 $src0, $src1), $src1)
+ >;
+} // End AddedComplexity = 20
+
+// V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector
+// case, the sgpr-copies pass will fix this to use the vector version.
+def : GCNPat <
+ (i32 (addc i32:$src0, i32:$src1)),
+ (S_ADD_U32 $src0, $src1)
+>;
----------------
jayfoad wrote:
Ping - this looks like it might have been a badly resolved merge conflict? Please remove this part.
https://github.com/llvm/llvm-project/pull/203155
More information about the llvm-commits
mailing list