[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)

Kaitlin Peng via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 3 15:10:45 PDT 2025


================
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
+
+// CHECK-LABEL: test_lit_half
+// CHECK-SAME: half noundef nofpclass(nan inf) [[NDOTL:%.*]], half noundef nofpclass(nan inf) [[NDOTH:%.*]], half noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTL]], 0xH0000
+// CHECK-NEXT:    [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.maxnum.f16(half [[NDOTL]], half 0xH0000)
+// CHECK-NEXT:    [[VECINIT2_I:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half 0xH3C00>, half [[HLSL_SELECT_I]], i64 1
+// CHECK-NEXT:    [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTH]], 0xH0000
+// CHECK-NEXT:    [[HLSL_OR_I:%.*]] = or i1 [[CMP_I]], [[CMP4_I]]
+// CHECK-NEXT:    [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.log.f16(half [[NDOTH]])
+// CHECK-NEXT:    [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[ELT_LOG_I]], [[M]]
+// CHECK-NEXT:    [[ELT_EXP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.exp.f16(half [[MUL_I]])
+// CHECK-NEXT:    [[HLSL_SELECT7_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[HLSL_OR_I]], half 0xH0000, half [[ELT_EXP_I]]
+// CHECK-NEXT:    [[VECINS_I:%.*]] = insertelement <4 x half> [[VECINIT2_I]], half [[HLSL_SELECT7_I]], i64 2
+// CHECK-NEXT:    ret <4 x half> [[VECINS_I]]
+//
----------------
kmpeng wrote:

Code updated

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


More information about the cfe-commits mailing list