Skip to content

Commit cbf5495

Browse files
committed
[RLE-DSE] port more tests to redundantloadelimination.sil
1 parent 63ff286 commit cbf5495

File tree

2 files changed

+63
-59
lines changed

2 files changed

+63
-59
lines changed

test/SILPasses/globalredundantloadelimination.sil

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -465,33 +465,6 @@ bb3:
465465
return %16 : $()
466466
}
467467

468-
// Check that we don't crash if the address is an unchecked_addr_cast.
469-
// CHECK-LABEL: sil @test_unchecked_addr_cast
470-
sil @test_unchecked_addr_cast : $@convention(thin) (@inout A, A) -> A {
471-
bb0(%0 : $*A, %1 : $A):
472-
%2 = unchecked_addr_cast %0 : $*A to $*A
473-
store %1 to %2 : $*A
474-
%l1 = load %2 : $*A
475-
return %l1 : $A
476-
}
477-
478-
// Multi-BB version of the previous test.
479-
// CHECK-LABEL: sil @test_forwarding_ignoring_unchecked_addr_cast2 : $@convention(thin) (@inout A, A, A) -> A {
480-
sil @test_forwarding_ignoring_unchecked_addr_cast2 : $@convention(thin) (@inout A, A, A) -> A {
481-
bb0(%0 : $*A, %1 : $A, %2: $A):
482-
%3 = unchecked_addr_cast %0 : $*A to $*A
483-
store %1 to %3 : $*A
484-
br bb1
485-
486-
bb1:
487-
%5 = load %3 : $*A
488-
%6 = load %3 : $*A
489-
store %2 to %3 : $*A
490-
cond_br undef, bb1, bb2
491-
492-
bb2:
493-
return %5 : $A
494-
}
495468

496469
// We internally use a map vector to represent stores. This means that when we iterate over
497470
// the stores it should be in insertion order. Use this to test whether or not we only set
@@ -520,38 +493,6 @@ bb0(%x : $D, %y : $D):
520493
return %l1 : $Builtin.RawPointer
521494
}
522495

523-
// CHECK-LABEL: sil @test_read_dependence_allows_forwarding_multi_bb_1 : $@convention(thin) (@inout A, A) -> A {
524-
// CHECK: bb0([[ARG_0:%.*]] : $*A, [[ARG_1:%.*]] : $A):
525-
// CHECK: store
526-
// CHECK: bb1:
527-
// CHECK-NEXT: load
528-
// CHECK-NEXT: store
529-
// CHECK-NEXT: cond_br
530-
// CHECK: bb2:
531-
// CHECK: return [[ARG_1]] : $A
532-
sil @test_read_dependence_allows_forwarding_multi_bb_1 : $@convention(thin) (@inout A, A) -> A {
533-
bb0(%0 : $*A, %1 : $A):
534-
store %1 to %0 : $*A
535-
%2 = unchecked_addr_cast %0 : $*A to $*A
536-
%3 = unchecked_addr_cast %2 : $*A to $*A
537-
br bb1
538-
539-
bb1:
540-
// This means that the first store is not dead.
541-
%4 = load %3 : $*A
542-
// But we still should be able to forward this load.
543-
%5 = load %0 : $*A
544-
// We need to dedup this store to trigger the self loop
545-
// forwarding. Once we do the full optimistic data flow this will no
546-
// longer be needed.
547-
%6 = load %0 : $*A
548-
store %1 to %0 : $*A
549-
cond_br undef, bb1, bb2
550-
551-
bb2:
552-
return %5 : $A
553-
}
554-
555496

556497
typealias I32 = Builtin.Int32
557498

test/SILPasses/redundantloadelimination.sil

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,69 @@ sil @escaped_a_ptr : $@convention(thin) (@out A) -> ()
104104
sil @escaped_a : $@convention(thin) () -> Builtin.RawPointer
105105
sil @init_twofield : $@convention(thin) (@thin TwoField.Type) -> TwoField
106106

107+
// Check that we don't crash if the address is an unchecked_addr_cast.
108+
// CHECK-LABEL: sil @test_unchecked_addr_cast
109+
// CHECK-NOT: load
110+
// CHECK: return
111+
sil @test_unchecked_addr_cast : $@convention(thin) (@inout A, A) -> A {
112+
bb0(%0 : $*A, %1 : $A):
113+
%2 = unchecked_addr_cast %0 : $*A to $*A
114+
store %1 to %2 : $*A
115+
%l1 = load %2 : $*A
116+
return %l1 : $A
117+
}
118+
119+
// Multi-BB version of the previous test.
120+
// CHECK-LABEL: sil @test_forwarding_ignoring_unchecked_addr_cast2 : $@convention(thin) (@inout A, A, A) -> A {
121+
// CHECK: bb1
122+
// CHECK-NOT: load
123+
// CHECK: cond_br
124+
sil @test_forwarding_ignoring_unchecked_addr_cast2 : $@convention(thin) (@inout A, A, A) -> A {
125+
bb0(%0 : $*A, %1 : $A, %2: $A):
126+
%3 = unchecked_addr_cast %0 : $*A to $*A
127+
store %1 to %3 : $*A
128+
br bb1
129+
130+
bb1:
131+
%5 = load %3 : $*A
132+
%6 = load %3 : $*A
133+
store %2 to %3 : $*A
134+
cond_br undef, bb1, bb2
135+
136+
bb2:
137+
return %5 : $A
138+
}
139+
140+
// CHECK-LABEL: sil @test_read_dependence_allows_forwarding_multi_bb_1 : $@convention(thin) (@inout A, A) -> A {
141+
// CHECK: bb0
142+
// CHECK: store
143+
// CHECK: bb1
144+
// CHECK: store
145+
// CHECK-NOT: load
146+
// CHECK: cond_br
147+
sil @test_read_dependence_allows_forwarding_multi_bb_1 : $@convention(thin) (@inout A, A) -> A {
148+
bb0(%0 : $*A, %1 : $A):
149+
store %1 to %0 : $*A
150+
%2 = unchecked_addr_cast %0 : $*A to $*A
151+
%3 = unchecked_addr_cast %2 : $*A to $*A
152+
br bb1
153+
154+
bb1:
155+
// This means that the first store is not dead.
156+
%4 = load %3 : $*A
157+
// But we still should be able to forward this load.
158+
%5 = load %0 : $*A
159+
// We need to dedup this store to trigger the self loop
160+
// forwarding. Once we do the full optimistic data flow this will no
161+
// longer be needed.
162+
%6 = load %0 : $*A
163+
store %1 to %0 : $*A
164+
cond_br undef, bb1, bb2
165+
166+
bb2:
167+
return %5 : $A
168+
}
169+
107170
// DISABLE this test for now. it seems DCE is not getting rid of the load in bb8 after the RLE happens.
108171
//
109172
// Make sure the switch does not affect the forwarding of the load.

0 commit comments

Comments
 (0)