[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 29 15:36:00 PDT 2025


================
@@ -106,3 +102,17 @@ float3 test_lerp_uint64_t3(uint64_t3 p0) { return lerp(p0, p0, p0); }
 // CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
 // CHECK: ret <4 x float> %hlsl.lerp
 float4 test_lerp_uint64_t4(uint64_t4 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_half_scalar
+// NATIVE_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.[[TARGET]].lerp.v3f16(<3 x half> %{{.*}}, <3 x half> %{{.*}}, <3 x half> %{{.*}})
+// NATIVE_HALF: ret <3 x half> %hlsl.lerp
+// NO_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
+// NO_HALF: ret <3 x float> %hlsl.lerp
+half3 test_lerp_half_scalar(half3 x, half3 y, half s) { return lerp(x, y, s); }
----------------
bogner wrote:

Yeah, that's not a bad idea. However, when I started to do that I realized this whole test file is a bit messed up - it's using `-disable-llvm-passes`, so none of the logic in the hlsl headers is inlined and we're actually splitting our checks across multiple functions in most of these cases o_O.

I'll put up an NFC PR to improve these tests and then follow up here shortly.

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


More information about the cfe-commits mailing list