@@ -136,26 +136,26 @@ func @nested_parallel(%0: memref<?x?x?xf64>) -> memref<?x?x?xf64> {
136
136
137
137
func private @side_effect ()
138
138
func @one_unused (%cond: i1 ) -> (index ) {
139
- %c0 = arith.constant 0 : index
140
- %c1 = arith.constant 1 : index
141
- %c2 = arith.constant 2 : index
142
- %c3 = arith.constant 3 : index
143
139
%0 , %1 = scf.if %cond -> (index , index ) {
144
140
call @side_effect () : () -> ()
141
+ %c0 = " test.value0" () : () -> (index )
142
+ %c1 = " test.value1" () : () -> (index )
145
143
scf.yield %c0 , %c1 : index , index
146
144
} else {
145
+ %c2 = " test.value2" () : () -> (index )
146
+ %c3 = " test.value3" () : () -> (index )
147
147
scf.yield %c2 , %c3 : index , index
148
148
}
149
149
return %1 : index
150
150
}
151
151
152
152
// CHECK-LABEL: func @one_unused
153
- // CHECK-DAG: [[C0:%.*]] = arith.constant 1 : index
154
- // CHECK-DAG: [[C3:%.*]] = arith.constant 3 : index
155
153
// CHECK: [[V0:%.*]] = scf.if %{{.*}} -> (index) {
156
154
// CHECK: call @side_effect() : () -> ()
157
- // CHECK: scf.yield [[C0]] : index
155
+ // CHECK: [[C1:%.*]] = "test.value1"
156
+ // CHECK: scf.yield [[C1]] : index
158
157
// CHECK: } else
158
+ // CHECK: [[C3:%.*]] = "test.value3"
159
159
// CHECK: scf.yield [[C3]] : index
160
160
// CHECK: }
161
161
// CHECK: return [[V0]] : index
@@ -164,37 +164,40 @@ func @one_unused(%cond: i1) -> (index) {
164
164
165
165
func private @side_effect ()
166
166
func @nested_unused (%cond1: i1 , %cond2: i1 ) -> (index ) {
167
- %c0 = arith.constant 0 : index
168
- %c1 = arith.constant 1 : index
169
- %c2 = arith.constant 2 : index
170
- %c3 = arith.constant 3 : index
171
167
%0 , %1 = scf.if %cond1 -> (index , index ) {
172
168
%2 , %3 = scf.if %cond2 -> (index , index ) {
173
169
call @side_effect () : () -> ()
170
+ %c0 = " test.value0" () : () -> (index )
171
+ %c1 = " test.value1" () : () -> (index )
174
172
scf.yield %c0 , %c1 : index , index
175
173
} else {
174
+ %c2 = " test.value2" () : () -> (index )
175
+ %c3 = " test.value3" () : () -> (index )
176
176
scf.yield %c2 , %c3 : index , index
177
177
}
178
178
scf.yield %2 , %3 : index , index
179
179
} else {
180
+ %c0 = " test.value0_2" () : () -> (index )
181
+ %c1 = " test.value1_2" () : () -> (index )
180
182
scf.yield %c0 , %c1 : index , index
181
183
}
182
184
return %1 : index
183
185
}
184
186
185
187
// CHECK-LABEL: func @nested_unused
186
- // CHECK-DAG: [[C0:%.*]] = arith.constant 1 : index
187
- // CHECK-DAG: [[C3:%.*]] = arith.constant 3 : index
188
188
// CHECK: [[V0:%.*]] = scf.if {{.*}} -> (index) {
189
189
// CHECK: [[V1:%.*]] = scf.if {{.*}} -> (index) {
190
190
// CHECK: call @side_effect() : () -> ()
191
- // CHECK: scf.yield [[C0]] : index
191
+ // CHECK: [[C1:%.*]] = "test.value1"
192
+ // CHECK: scf.yield [[C1]] : index
192
193
// CHECK: } else
194
+ // CHECK: [[C3:%.*]] = "test.value3"
193
195
// CHECK: scf.yield [[C3]] : index
194
196
// CHECK: }
195
197
// CHECK: scf.yield [[V1]] : index
196
198
// CHECK: } else
197
- // CHECK: scf.yield [[C0]] : index
199
+ // CHECK: [[C1_2:%.*]] = "test.value1_2"
200
+ // CHECK: scf.yield [[C1_2]] : index
198
201
// CHECK: }
199
202
// CHECK: return [[V0]] : index
200
203
@@ -302,6 +305,27 @@ func @to_select_same_val(%cond: i1) -> (index, index) {
302
305
// CHECK: [[V0:%.*]] = arith.select {{.*}}, [[C0]], [[C1]]
303
306
// CHECK: return [[V0]], [[C1]] : index, index
304
307
308
+
309
+ func @to_select_with_body (%cond: i1 ) -> index {
310
+ %c0 = arith.constant 0 : index
311
+ %c1 = arith.constant 1 : index
312
+ %0 = scf.if %cond -> index {
313
+ " test.op" () : () -> ()
314
+ scf.yield %c0 : index
315
+ } else {
316
+ scf.yield %c1 : index
317
+ }
318
+ return %0 : index
319
+ }
320
+
321
+ // CHECK-LABEL: func @to_select_with_body
322
+ // CHECK-DAG: [[C0:%.*]] = arith.constant 0 : index
323
+ // CHECK-DAG: [[C1:%.*]] = arith.constant 1 : index
324
+ // CHECK: scf.if {{.*}} {
325
+ // CHECK: "test.op"() : () -> ()
326
+ // CHECK: }
327
+ // CHECK: [[V0:%.*]] = arith.select {{.*}}, [[C0]], [[C1]]
328
+ // CHECK: return [[V0]] : index
305
329
// -----
306
330
307
331
func @to_select2 (%cond: i1 ) -> (index , index ) {
@@ -731,38 +755,32 @@ func @matmul_on_tensors(%t0: tensor<32x1024xf32>, %t1: tensor<1024x1024xf32>) ->
731
755
732
756
// CHECK-LABEL: @cond_prop
733
757
func @cond_prop (%arg0 : i1 ) -> index {
734
- %c1 = arith.constant 1 : index
735
- %c2 = arith.constant 2 : index
736
- %c3 = arith.constant 3 : index
737
- %c4 = arith.constant 4 : index
738
758
%res = scf.if %arg0 -> index {
739
759
%res1 = scf.if %arg0 -> index {
740
- %v1 = " test.get_some_value " () : () -> i32
741
- scf.yield %c1 : index
760
+ %v1 = " test.get_some_value1 " () : () -> index
761
+ scf.yield %v1 : index
742
762
} else {
743
- %v2 = " test.get_some_value " () : () -> i32
744
- scf.yield %c2 : index
763
+ %v2 = " test.get_some_value2 " () : () -> index
764
+ scf.yield %v2 : index
745
765
}
746
766
scf.yield %res1 : index
747
767
} else {
748
768
%res2 = scf.if %arg0 -> index {
749
- %v3 = " test.get_some_value " () : () -> i32
750
- scf.yield %c3 : index
769
+ %v3 = " test.get_some_value3 " () : () -> index
770
+ scf.yield %v3 : index
751
771
} else {
752
- %v4 = " test.get_some_value " () : () -> i32
753
- scf.yield %c4 : index
772
+ %v4 = " test.get_some_value4 " () : () -> index
773
+ scf.yield %v4 : index
754
774
}
755
775
scf.yield %res2 : index
756
776
}
757
777
return %res : index
758
778
}
759
- // CHECK-DAG: %[[c1:.+]] = arith.constant 1 : index
760
- // CHECK-DAG: %[[c4:.+]] = arith.constant 4 : index
761
779
// CHECK-NEXT: %[[if:.+]] = scf.if %arg0 -> (index) {
762
- // CHECK-NEXT: %{{.+}} = "test.get_some_value "() : () -> i32
780
+ // CHECK-NEXT: %[[c1:.+]] = "test.get_some_value1 "() : () -> index
763
781
// CHECK-NEXT: scf.yield %[[c1]] : index
764
782
// CHECK-NEXT: } else {
765
- // CHECK-NEXT: %{{.+}} = "test.get_some_value "() : () -> i32
783
+ // CHECK-NEXT: %[[c4:.+]] = "test.get_some_value4 "() : () -> index
766
784
// CHECK-NEXT: scf.yield %[[c4]] : index
767
785
// CHECK-NEXT: }
768
786
// CHECK-NEXT: return %[[if]] : index
@@ -808,14 +826,14 @@ func @replace_if_with_cond2(%arg0 : i1) -> (i32, i1) {
808
826
return %res#0 , %res#1 : i32 , i1
809
827
}
810
828
// CHECK-NEXT: %true = arith.constant true
811
- // CHECK-NEXT: %[[toret:.+]] = arith.xori %arg0, %true : i1
812
829
// CHECK-NEXT: %[[if:.+]] = scf.if %arg0 -> (i32) {
813
830
// CHECK-NEXT: %[[sv1:.+]] = "test.get_some_value"() : () -> i32
814
831
// CHECK-NEXT: scf.yield %[[sv1]] : i32
815
832
// CHECK-NEXT: } else {
816
833
// CHECK-NEXT: %[[sv2:.+]] = "test.get_some_value"() : () -> i32
817
834
// CHECK-NEXT: scf.yield %[[sv2]] : i32
818
835
// CHECK-NEXT: }
836
+ // CHECK-NEXT: %[[toret:.+]] = arith.xori %arg0, %true : i1
819
837
// CHECK-NEXT: return %[[if]], %[[toret]] : i32, i1
820
838
821
839
// -----
0 commit comments