[llvm] [DXIL] Add radians intrinsic (PR #110616)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 12:59:28 PDT 2024


================
@@ -0,0 +1,56 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S  -dxil-op-lower  -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
+
+declare half @llvm.dx.radians.f16(half)
+declare float @llvm.dx.radians.f32(float)
+
+declare <4 x half> @llvm.dx.radians.v4f16(<4 x half>)
+declare <4 x float> @llvm.dx.radians.v4f32(<4 x float>)
+
+define noundef half @radians_half(half noundef %a) {
+; CHECK-LABEL: define noundef half @radians_half(
+; CHECK-SAME: half noundef [[A:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[TMP0:%.*]] = fmul half [[A]], 0xH2478
+; CHECK-NEXT:    ret half [[TMP0]]
+;
+entry:
+  %elt.radians = call half @llvm.dx.radians.f16(half %a)
+  ret half %elt.radians
+}
+
+define noundef float @radians_float(float noundef %a) {
+; CHECK-LABEL: define noundef float @radians_float(
+; CHECK-SAME: float noundef [[A:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[TMP0:%.*]] = fmul float [[A]], 0x3F91DF46A0000000
+; CHECK-NEXT:    ret float [[TMP0]]
+;
+entry:
+  %elt.radians = call float @llvm.dx.radians.f32(float %a)
+  ret float %elt.radians
+}
+
+define noundef <4 x half> @radians_half_vector(<4 x half> noundef %a) {
+; CHECK-LABEL: define noundef <4 x half> @radians_half_vector(
+; CHECK-SAME: <4 x half> noundef [[A:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[TMP0:%.*]] = fmul <4 x half> [[A]], <half 0xH2478, half 0xH2478, half 0xH2478, half 0xH2478>
+; CHECK-NEXT:    ret <4 x half> [[TMP0]]
+;
+entry:
+  %elt.radians = call <4 x half> @llvm.dx.radians.v4f16(<4 x half> %a)
+  ret <4 x half> %elt.radians
+}
+
+define noundef <4 x float> @radians_float_vector(<4 x float> noundef %a) {
+; CHECK-LABEL: define noundef <4 x float> @radians_float_vector(
+; CHECK-SAME: <4 x float> noundef [[A:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[TMP0:%.*]] = fmul <4 x float> [[A]], <float 0x3F91DF46A0000000, float 0x3F91DF46A0000000, float 0x3F91DF46A0000000, float 0x3F91DF46A0000000>
----------------
farzonl wrote:

after you add the scalarization pass check this fmul and the one in the half test should be scalarized. 

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


More information about the llvm-commits mailing list