1 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -verify-memoryssa -S %s | FileCheck %s
4 target triple = "x86_64-unknown-linux-gnu"
8 ; In Test1, there are no definitions. MemorySSA updates insert trivial phis and remove them.
9 ; Verify all are removed, considering the SLU pass leaves unreachable blocks hanging when the MSSA updates are done.
11 define void @Test1(i32) {
15 outer.loopexit.split: ; preds = %continue
16 br label %outer.loopexit
18 outer.loopexit: ; preds = %outer.loopexit.split.us, %outer.loopexit.split
21 outer: ; preds = %outer.loopexit, %header
22 br i1 false, label %outer.split.us, label %outer.split
24 outer.split.us: ; preds = %outer
27 inner.us: ; preds = %continue.us, %outer.split.us
30 overflow.us: ; preds = %inner.us
33 continue.us: ; preds = %overflow.us
34 br i1 true, label %outer.loopexit.split.us, label %inner.us
36 outer.loopexit.split.us: ; preds = %continue.us
37 br label %outer.loopexit
39 outer.split: ; preds = %outer
42 inner: ; preds = %continue, %outer.split
45 switchme: ; preds = %inner
46 switch i32 %0, label %continue [
51 case2: ; preds = %switchme
54 continue: ; preds = %case2, %switchme
55 br i1 true, label %outer.loopexit.split, label %inner
57 go_out: ; preds = %switchme
61 ; In Test2 there is a single def (call to foo). There are already Phis in place that are cloned when unswitching.
62 ; Ensure MemorySSA remains correct. Due to SLU's pruned cloning, continue.us2 becomes unreachable, with an empty Phi that is later cleaned.
64 define void @Test2(i32) {
68 outer.loopexit.split: ; preds = %continue
69 br label %outer.loopexit
71 outer.loopexit: ; preds = %outer.loopexit.split.us, %outer.loopexit.split
74 outer: ; preds = %outer.loopexit, %header
75 br i1 false, label %outer.split.us, label %outer.split
77 outer.split.us: ; preds = %outer
80 inner.us: ; preds = %continue.us, %outer.split.us
83 overflow.us: ; preds = %inner.us
86 continue.us: ; preds = %overflow.us
87 br i1 true, label %outer.loopexit.split.us, label %inner.us
89 outer.loopexit.split.us: ; preds = %continue.us
90 br label %outer.loopexit
92 outer.split: ; preds = %outer
95 inner: ; preds = %continue, %outer.split
98 switchme: ; preds = %inner
99 switch i32 %0, label %continue [
100 i32 88, label %go_out
104 case2: ; preds = %switchme
108 continue: ; preds = %case2, %switchme
109 br i1 true, label %outer.loopexit.split, label %inner
111 go_out: ; preds = %switchme