[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 18:02:54 PST 2025


================
@@ -738,6 +739,16 @@ def UMin : DXILOp<40, binary> {
   let attributes = [Attributes<DXIL1_0, [ReadNone]>];
 }
 
+def UAddc : DXILOp<44, binaryWithCarryOrBorrow > {
+  let Doc = "Unsigned 32-bit integer arithmetic add with carry. uaddc(a,b) = (a+b, a+b overflowed ? 1 : 0)";
+  let intrinsics = [IntrinSelect<int_uadd_with_overflow>];
----------------
farzonl wrote:

This isn't a nice tablegen solution, but we have the power to check  if we have a non 32 bit case in `DXILIntrinsicExpansion.cpp`. It would be a little bit of a new pattern for us because it would be the first time we check an intrinsic  and might not apply a transformation.

Downside is it assumes the DXIL version doesn't update UAddc for other types and if it ever did we would have to introduces some versioning to only do this for pre DXIL 1.6.x.

Upside it lets you keep the  direct mapping of `int_uadd_with_overflow` to `UAddc` and only modify for the expansion cases.

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


More information about the cfe-commits mailing list