1; RUN: opt < %s -gvn-hoist -S | FileCheck %s
2
3; This test is meant to make sure that MemorySSAUpdater works correctly
4; in non-trivial cases.
5
6; CHECK: if.else218:
7; CHECK-NEXT: %0 = getelementptr inbounds %s, %s* undef, i32 0, i32 0
8; CHECK-NEXT: %1 = load i32, i32* %0, align 4
9
10target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
11
12%s = type { i32, %s**, [3 x i8], i8 }
13
14define void @test() {
15entry:
16  br label %cond.end118
17
18cond.end118:                                      ; preds = %entry
19  br i1 undef, label %cleanup, label %if.end155
20
21if.end155:                                        ; preds = %cond.end118
22  br label %while.cond
23
24while.cond:                                       ; preds = %while.body, %if.end155
25  br i1 undef, label %while.end, label %while.body
26
27while.body:                                       ; preds = %while.cond
28  br label %while.cond
29
30while.end:                                        ; preds = %while.cond
31  switch i32 undef, label %if.else218 [
32    i32 1, label %cleanup
33    i32 0, label %if.then174
34  ]
35
36if.then174:                                       ; preds = %while.end
37  unreachable
38
39if.else218:                                       ; preds = %while.end
40  br i1 undef, label %if.then226, label %if.else326
41
42if.then226:                                       ; preds = %if.else218
43  %size227 = getelementptr inbounds %s, %s* undef, i32 0, i32 0
44  %0 = load i32, i32* %size227, align 4
45  unreachable
46
47if.else326:                                       ; preds = %if.else218
48  %size330 = getelementptr inbounds %s, %s* undef, i32 0, i32 0
49  %1 = load i32, i32* %size330, align 4
50  unreachable
51
52cleanup:                                          ; preds = %while.end, %cond.end118
53  ret void
54}
55