[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 4 18:14:10 PDT 2024


================
@@ -489,6 +542,9 @@ class OpLowerer {
       case Intrinsic::dx_typedBufferStore:
         HasErrors |= lowerTypedBufferStore(F);
         break;
+      case Intrinsic::dx_splitdouble:
----------------
bogner wrote:

There will need to be some logic in DXILOpLowering, because we need to change the return type. The DirectX intrinsic returns an anonymous struct, `{i32, i32}`, whereas the DXIL op returns a named struct, `%dx.types.splitdouble`. So we do need to update that when replacing uses, from:
```llvm
  %hlsl.splitdouble = call { i32, i32 } @llvm.dx.splitdouble.i32(double %v)
  %0 = extractvalue { i32, i32 } %hlsl.splitdouble, 0
  %1 = extractvalue { i32, i32 } %hlsl.splitdouble, 1
```
to
```
  %hlsl.splitdouble = call %dx.types.splitdouble @dx.op.splitDouble.f64(i32 102, double %v)
  %0 = extractvalue %dx.types.splitdouble %hlsl.splitdouble, 0
  %1 = extractvalue %dx.types.splitdouble %hlsl.splitdouble, 1
```

We don't currently have the ability to do that automatically in DXILOpLowering.

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


More information about the cfe-commits mailing list