Skip to content

Commit 07aa4e5

Browse files
committed
Remove return after else
1 parent 6daff55 commit 07aa4e5

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

libclc/ptx-nvidiacl/libspirv/math/native_exp2.cl

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,24 @@
1919
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
2020

2121
int __clc_nvvm_reflect_arch();
22+
#define __USE_HALF_EXP2_APPROX (__clc_nvvm_reflect_arch() >= 750)
2223

2324
_CLC_DEF _CLC_OVERLOAD half __clc_native_exp2(half x) {
24-
if (__clc_nvvm_reflect_arch() >= 750) {
25-
return __nvvm_ex2_approx_f16(x);
26-
} else {
27-
float upcast = x;
28-
return __spirv_ocl_native_exp2(upcast);
29-
}
25+
return (__USE_HALF_EXP2_APPROX) ? __nvvm_ex2_approx_f16(x)
26+
: __spirv_ocl_native_exp2((float)x);
3027
}
3128

3229
_CLC_DEF _CLC_OVERLOAD half2 __clc_native_exp2(half2 x) {
33-
if (__clc_nvvm_reflect_arch() >= 750) {
34-
return __nvvm_ex2_approx_f16x2(x);
35-
} else {
36-
float upcast0 = x[0];
37-
float upcast1 = x[1];
38-
half2 res;
39-
res.s0 = __spirv_ocl_native_exp2(upcast0);
40-
res.s1 = __spirv_ocl_native_exp2(upcast1);
41-
return res;
42-
}
30+
return (__USE_HALF_EXP2_APPROX)
31+
? __nvvm_ex2_approx_f16x2(x)
32+
: (half2)(__spirv_ocl_native_exp2((float)x.x),
33+
__spirv_ocl_native_exp2((float)x.y));
4334
}
4435

45-
_CLC_UNARY_VECTORIZE_HAVE2(_CLC_OVERLOAD _CLC_DEF, half,
46-
__clc_native_exp2, half)
36+
_CLC_UNARY_VECTORIZE_HAVE2(_CLC_OVERLOAD _CLC_DEF, half, __clc_native_exp2,
37+
half)
38+
39+
#undef __USE_HALF_EXP2_APPROX
4740

4841
#endif // cl_khr_fp16
4942

0 commit comments

Comments
 (0)