xref: /llvm-project/llvm/test/CodeGen/DirectX/ShaderFlags/propagate-function-flags-test.ll (revision a4b7a2d021ca7371752f0e8180200ffd7b48ca70)
1; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
2
3target triple = "dxil-pc-shadermodel6.7-library"
4
5; CHECK: ; Combined Shader Flags for Module
6; CHECK-NEXT: ; Shader Flags Value: 0x00000044
7; CHECK-NEXT: ;
8; CHECK-NEXT: ; Note: shader requires additional functionality:
9; CHECK-NEXT: ;       Double-precision floating point
10; CHECK-NEXT: ;       Double-precision extensions for 11.1
11; CHECK-NEXT: ; Note: extra DXIL module flags:
12; CHECK-NEXT: ;
13; CHECK-NEXT: ; Shader Flags for Module Functions
14
15; Call Graph of test source
16; main        -> [get_fptoui_flag, get_sitofp_fdiv_flag]
17; get_fptoui_flag  -> [get_sitofp_uitofp_flag, call_get_uitofp_flag]
18; get_sitofp_uitofp_flag  -> [call_get_fptoui_flag, call_get_sitofp_flag]
19; call_get_fptoui_flag  -> [get_fptoui_flag]
20; get_sitofp_fdiv_flag -> [get_no_flags, get_all_doubles_flags]
21; get_all_doubles_flags -> [call_get_sitofp_fdiv_flag]
22; call_get_sitofp_fdiv_flag  -> [get_sitofp_fdiv_flag]
23; call_get_sitofp_flag  -> [get_sitofp_flag]
24; call_get_uitofp_flag  -> [get_uitofp_flag]
25; get_sitofp_flag  -> []
26; get_uitofp_flag  -> []
27; get_no_flags  -> []
28;
29; Strongly Connected Component in the CG
30;  [get_fptoui_flag, get_sitofp_uitofp_flag, call_get_fptoui_flag]
31;  [get_sitofp_fdiv_flag, get_all_doubles_flags, call_get_sitofp_fdiv_flag]
32
33;
34; CHECK: ; Function get_sitofp_flag  : 0x00000044
35define double @get_sitofp_flag(i32 noundef %0) local_unnamed_addr #0 {
36  %2 = sitofp i32 %0 to double
37  ret double %2
38}
39
40; CHECK: ; Function call_get_sitofp_flag : 0x00000044
41define double @call_get_sitofp_flag(i32 noundef %0) local_unnamed_addr #0 {
42  %2 = tail call double @get_sitofp_flag(i32 noundef %0)
43  ret double %2
44}
45
46; CHECK: ; Function get_uitofp_flag : 0x00000044
47define double @get_uitofp_flag(i32 noundef %0) local_unnamed_addr #0 {
48  %2 = uitofp i32 %0 to double
49  ret double %2
50}
51
52; CHECK: ; Function call_get_uitofp_flag : 0x00000044
53define double @call_get_uitofp_flag(i32 noundef %0) local_unnamed_addr #0 {
54  %2 = tail call double @get_uitofp_flag(i32 noundef %0)
55  ret double %2
56}
57
58; CHECK: ; Function call_get_fptoui_flag : 0x00000044
59define double @call_get_fptoui_flag(double noundef %0) local_unnamed_addr #0 {
60  %2 = tail call double @get_fptoui_flag(double noundef %0)
61  ret double %2
62}
63
64; CHECK: ; Function get_fptoui_flag : 0x00000044
65define double @get_fptoui_flag(double noundef %0) local_unnamed_addr #0 {
66  %2 = fcmp ugt double %0, 5.000000e+00
67  br i1 %2, label %6, label %3
68
693:                                                ; preds = %1
70  %4 = fptoui double %0 to i64
71  %5 = tail call double @get_sitofp_uitofp_flag(i64 noundef %4)
72  br label %9
73
746:                                                ; preds = %1
75  %7 = fptoui double %0 to i32
76  %8 = tail call double @call_get_uitofp_flag(i32 noundef %7)
77  br label %9
78
799:                                                ; preds = %6, %3
80  %10 = phi double [ %5, %3 ], [ %8, %6 ]
81  ret double %10
82}
83
84; CHECK: ; Function get_sitofp_uitofp_flag : 0x00000044
85define double @get_sitofp_uitofp_flag(i64 noundef %0) local_unnamed_addr #0 {
86  %2 = icmp ult i64 %0, 6
87  br i1 %2, label %3, label %7
88
893:                                                ; preds = %1
90  %4 = add nuw nsw i64 %0, 1
91  %5 = uitofp i64 %4 to double
92  %6 = tail call double @call_get_fptoui_flag(double noundef %5)
93  br label %10
94
957:                                                ; preds = %1
96  %8 = trunc i64 %0 to i32
97  %9 = tail call double @call_get_sitofp_flag(i32 noundef %8)
98  br label %10
99
10010:                                               ; preds = %7, %3
101  %11 = phi double [ %6, %3 ], [ %9, %7 ]
102  ret double %11
103}
104
105; CHECK: ; Function get_no_flags : 0x00000000
106define i32 @get_no_flags(i32 noundef %0) local_unnamed_addr #0 {
107  %2 = mul nsw i32 %0, %0
108  ret i32 %2
109}
110
111; CHECK: ; Function call_get_sitofp_fdiv_flag : 0x00000044
112define i32 @call_get_sitofp_fdiv_flag(i32 noundef %0) local_unnamed_addr #0 {
113  %2 = icmp eq i32 %0, 0
114  br i1 %2, label %5, label %3
115
1163:                                                ; preds = %1
117  %4 = mul nsw i32 %0, %0
118  br label %7
119
1205:                                                ; preds = %1
121  %6 = tail call double @get_sitofp_fdiv_flag(i32 noundef 0)
122  br label %7
123
1247:                                                ; preds = %5, %3
125  %8 = phi i32 [ %4, %3 ], [ 0, %5 ]
126  ret i32 %8
127}
128
129; CHECK: ; Function get_sitofp_fdiv_flag : 0x00000044
130define double @get_sitofp_fdiv_flag(i32 noundef %0) local_unnamed_addr #0 {
131  %2 = icmp sgt i32 %0, 5
132  br i1 %2, label %3, label %6
133
1343:                                                ; preds = %1
135  %4 = tail call i32 @get_no_flags(i32 noundef %0)
136  %5 = sitofp i32 %4 to double
137  br label %9
138
1396:                                                ; preds = %1
140  %7 = tail call double @get_all_doubles_flags(i32 noundef %0)
141  %8 = fdiv double %7, 3.000000e+00
142  br label %9
143
1449:                                                ; preds = %6, %3
145  %10 = phi double [ %5, %3 ], [ %8, %6 ]
146  ret double %10
147}
148
149; CHECK: ; Function get_all_doubles_flags : 0x00000044
150define double @get_all_doubles_flags(i32 noundef %0) local_unnamed_addr #0 {
151  %2 = tail call i32 @call_get_sitofp_fdiv_flag(i32 noundef %0)
152  %3 = icmp eq i32 %2, 0
153  %4 = select i1 %3, double 1.000000e+01, double 1.000000e+02
154  ret double %4
155}
156
157; CHECK: ; Function main : 0x00000044
158define i32 @main() local_unnamed_addr #0 {
159  %1 = tail call double @get_fptoui_flag(double noundef 1.000000e+00)
160  %2 = tail call double @get_sitofp_fdiv_flag(i32 noundef 4)
161  %3 = fadd double %1, %2
162  %4 = fcmp ogt double %3, 0.000000e+00
163  %5 = zext i1 %4 to i32
164  ret i32 %5
165}
166
167attributes #0 = { convergent norecurse nounwind "hlsl.export"}
168