Skip to content

Commit c3ce717

Browse files
committed
allow bool overload, add bool test
1 parent 2460593 commit c3ce717

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

clang/lib/Headers/hlsl/hlsl_compat_overloads.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,8 @@ _DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp)
286286

287287
template <typename T>
288288
constexpr __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
289-
(__detail::is_same<double, T>::value ||
290-
__detail::is_same<int, T>::value ||
291-
__detail::is_same<uint, T>::value ||
292-
__detail::is_same<int64_t, T>::value ||
293-
__detail::is_same<uint64_t, T>::value),
289+
!__detail::is_same<half, T>::value &&
290+
!__detail::is_same<float, T>::value,
294291
vector<T, 4>>
295292
lit(T NDotL, T NDotH, T M) {
296293
return lit((float)NDotL, (float)NDotH, (float)M);

clang/test/CodeGenHLSL/builtins/lit-overloads.hlsl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,21 @@ int64_t4 test_lit_int64_t(int64_t NDotL, int64_t NDotH, int64_t M) { return lit(
9191
// CHECK: %conv3.i = fptoui <4 x float> %{{.*}} to <4 x i64>
9292
// CHECK: ret <4 x i64> %conv3.i
9393
uint64_t4 test_lit_uint64_t(uint64_t NDotL, uint64_t NDotH, uint64_t M) { return lit(NDotL, NDotH, M); }
94+
95+
// CHECK-LABEL: test_lit_bool
96+
// CHECK: %conv.i = uitofp i1 %{{.*}} to float
97+
// CHECK: %conv4.i = uitofp i1 %{{.*}} to float
98+
// CHECK: %conv6.i = uitofp i1 %{{.*}} to float
99+
// CHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn olt float %{{.*}}, 0.000000e+00
100+
// CHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn i1 %{{.*}}, float 0.000000e+00, float %{{.*}}
101+
// CHECK: %vecinit.i = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float %{{.*}}, i32 1
102+
// CHECK: %cmp4.i = fcmp reassoc nnan ninf nsz arcp afn olt float %{{.*}}, 0.000000e+00
103+
// CHECK: %hlsl.or.i = or i1 %{{.*}}, %cmp4.i
104+
// CHECK: %elt.log.i = call reassoc nnan ninf nsz arcp afn float @llvm.log.f32(float %{{.*}})
105+
// CHECK: %mul.i = fmul reassoc nnan ninf nsz arcp afn float %elt.log.i, %{{.*}}
106+
// CHECK: %elt.exp.i = call reassoc nnan ninf nsz arcp afn float @llvm.exp.f32(float %mul.i)
107+
// CHECK: %hlsl.select7.i = select reassoc nnan ninf nsz arcp afn i1 %{{.*}}, float 0.000000e+00, float %{{.*}}
108+
// CHECK: %vecins.i = insertelement <4 x float> %{{.*}}, float %hlsl.select7.i, i32 2
109+
// CHECK: %tobool.i = fcmp reassoc nnan ninf nsz arcp afn une <4 x float> %{{.*}}, zeroinitializer
110+
// CHECK: ret <4 x i1> %tobool.i
111+
bool4 test_lit_bool(bool NDotL, bool NDotH, bool M) { return lit(NDotL, NDotH, M); }

0 commit comments

Comments
 (0)