xref: /llvm-project/llvm/test/Analysis/CostModel/RISCV/phi-const.ll (revision 0a5d52a757f389b4f7ee3ee1ad6840ff7ce33e51)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2; RUN: opt < %s -mtriple=riscv64 -mattr=+f,+d -disable-output -passes="print<cost-model>" 2>&1 | FileCheck %s
3
4define i8 @phi_i8(i1 %c) {
5; CHECK-LABEL: 'phi_i8'
6; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
7; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
8; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
9; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i8 [ 16, %a ], [ 32, %b ]
10; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i8 %x
11;
12  br i1 %c, label %a, label %b
13a:
14  br label %d
15b:
16  br label %d
17d:
18  %x = phi i8 [16, %a], [32, %b]
19  ret i8 %x
20}
21
22define i16 @phi_i16_small(i1 %c) {
23; CHECK-LABEL: 'phi_i16_small'
24; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
25; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
26; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
27; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i16 [ 1, %a ], [ 2, %b ]
28; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i16 %x
29;
30  br i1 %c, label %a, label %b
31a:
32  br label %d
33b:
34  br label %d
35d:
36  %x = phi i16 [1, %a], [2, %b]
37  ret i16 %x
38}
39
40define i16 @phi_i16_large(i1 %c) {
41; CHECK-LABEL: 'phi_i16_large'
42; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
43; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
44; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
45; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i16 [ 42, %a ], [ -7616, %b ]
46; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i16 %x
47;
48  br i1 %c, label %a, label %b
49a:
50  br label %d
51b:
52  br label %d
53d:
54  %x = phi i16 [42, %a], [123456, %b]
55  ret i16 %x
56}
57
58define i32 @phi_i32_small(i1 %c) {
59; CHECK-LABEL: 'phi_i32_small'
60; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
61; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
62; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
63; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i32 [ 1, %a ], [ 2, %b ]
64; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x
65;
66  br i1 %c, label %a, label %b
67a:
68  br label %d
69b:
70  br label %d
71d:
72  %x = phi i32 [1, %a], [2, %b]
73  ret i32 %x
74}
75
76define i32 @phi_i32_large(i1 %c) {
77; CHECK-LABEL: 'phi_i32_large'
78; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
79; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
80; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
81; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i32 [ 42, %a ], [ 123456, %b ]
82; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x
83;
84  br i1 %c, label %a, label %b
85a:
86  br label %d
87b:
88  br label %d
89d:
90  %x = phi i32 [42, %a], [123456, %b]
91  ret i32 %x
92}
93
94define i64 @phi_i64_small(i1 %c) {
95; CHECK-LABEL: 'phi_i64_small'
96; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
97; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
98; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
99; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i64 [ 1, %a ], [ 2, %b ]
100; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %x
101;
102  br i1 %c, label %a, label %b
103a:
104  br label %d
105b:
106  br label %d
107d:
108  %x = phi i64 [1, %a], [2, %b]
109  ret i64 %x
110}
111
112define i64 @phi_i64_large(i1 %c) {
113; CHECK-LABEL: 'phi_i64_large'
114; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
115; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
116; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
117; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi i64 [ 42, %a ], [ 123456, %b ]
118; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %x
119;
120  br i1 %c, label %a, label %b
121a:
122  br label %d
123b:
124  br label %d
125d:
126  %x = phi i64 [42, %a], [123456, %b]
127  ret i64 %x
128}
129
130define half @phi_f16(i1 %c) {
131; CHECK-LABEL: 'phi_f16'
132; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
133; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
134; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
135; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi half [ 0xHE3CE, %a ], [ 0xH5144, %b ]
136; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret half %x
137;
138  br i1 %c, label %a, label %b
139a:
140  br label %d
141b:
142  br label %d
143d:
144  %x = phi half [-999.0, %a], [42.125, %b]
145  ret half %x
146}
147
148define float @phi_f32(i1 %c) {
149; CHECK-LABEL: 'phi_f32'
150; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
151; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
152; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
153; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi float [ -9.990000e+02, %a ], [ 4.212500e+01, %b ]
154; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret float %x
155;
156  br i1 %c, label %a, label %b
157a:
158  br label %d
159b:
160  br label %d
161d:
162  %x = phi float [-999.0, %a], [42.125, %b]
163  ret float %x
164}
165
166define double @phi_f64(i1 %c) {
167; CHECK-LABEL: 'phi_f64'
168; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
169; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
170; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: br label %d
171; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %x = phi double [ -9.990000e+02, %a ], [ 4.212500e+01, %b ]
172; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret double %x
173;
174  br i1 %c, label %a, label %b
175a:
176  br label %d
177b:
178  br label %d
179d:
180  %x = phi double [-999.0, %a], [42.125, %b]
181  ret double %x
182}
183