1; RUN: opt -alignment-from-assumptions -S < %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-unknown-linux-gnu"
4
5%type1 = type { %type2 }
6%type2 = type { [4 x i8] }
7
8; Function Attrs: nounwind
9declare void @llvm.assume(i1) #0
10
11; Function Attrs: nounwind readnone
12declare i32 @llvm.bswap.i32(i32) #1
13
14; Function Attrs: nounwind uwtable
15define void @test1() unnamed_addr #2 align 2 {
16
17; CHECK-LABEL: @test1
18
19entry:
20  br i1 undef, label %if.then, label %if.end
21
22if.then:                                          ; preds = %entry
23  unreachable
24
25if.end:                                           ; preds = %entry
26  br i1 undef, label %return, label %if.end8
27
28if.end8:                                          ; preds = %if.end
29  br i1 undef, label %if.then13, label %if.end14
30
31if.then13:                                        ; preds = %if.end8
32  unreachable
33
34if.end14:                                         ; preds = %if.end8
35  br i1 undef, label %cond.false.i129, label %cond.end.i136
36
37cond.false.i129:                                  ; preds = %if.end14
38  unreachable
39
40cond.end.i136:                                    ; preds = %if.end14
41  br i1 undef, label %land.lhs.true.i, label %if.end.i145
42
43land.lhs.true.i:                                  ; preds = %cond.end.i136
44  br i1 undef, label %if.end.i145, label %if.then.i137
45
46if.then.i137:                                     ; preds = %land.lhs.true.i
47  br i1 undef, label %cond.false8.i, label %cond.end9.i
48
49cond.false8.i:                                    ; preds = %if.then.i137
50  unreachable
51
52cond.end9.i:                                      ; preds = %if.then.i137
53  br i1 undef, label %if.then23, label %if.end24
54
55if.end.i145:                                      ; preds = %land.lhs.true.i, %cond.end.i136
56  unreachable
57
58if.then23:                                        ; preds = %cond.end9.i
59  unreachable
60
61if.end24:                                         ; preds = %cond.end9.i
62  br i1 undef, label %for.end, label %for.body.lr.ph
63
64for.body.lr.ph:                                   ; preds = %if.end24
65  unreachable
66
67for.end:                                          ; preds = %if.end24
68  br i1 undef, label %if.end123, label %if.then121
69
70if.then121:                                       ; preds = %for.end
71  unreachable
72
73if.end123:                                        ; preds = %for.end
74  br i1 undef, label %if.end150, label %if.then126
75
76if.then126:                                       ; preds = %if.end123
77  %ptrint.i.i185 = ptrtoint %type1* undef to i64
78  %maskedptr.i.i186 = and i64 %ptrint.i.i185, 1
79  %maskcond.i.i187 = icmp eq i64 %maskedptr.i.i186, 0
80  tail call void @llvm.assume(i1 %maskcond.i.i187) #0
81  %ret.0..sroa_cast.i.i188 = bitcast %type1* undef to i32*
82  %ret.0.copyload.i.i189 = load i32* %ret.0..sroa_cast.i.i188, align 2
83
84; CHECK: load {{.*}} align 2
85
86  %0 = tail call i32 @llvm.bswap.i32(i32 %ret.0.copyload.i.i189) #0
87  %conv131 = zext i32 %0 to i64
88  %add.ptr132 = getelementptr inbounds i8* undef, i64 %conv131
89  %1 = bitcast i8* %add.ptr132 to %type1*
90  br i1 undef, label %if.end150, label %if.end.i173
91
92if.end.i173:                                      ; preds = %if.then126
93  br i1 undef, label %test1.exit, label %cond.false.i.i.i.i174
94
95cond.false.i.i.i.i174:                            ; preds = %if.end.i173
96  unreachable
97
98test1.exit: ; preds = %if.end.i173
99  br i1 undef, label %test1a.exit, label %if.end.i124
100
101if.end.i124:                                      ; preds = %test1.exit
102  unreachable
103
104test1a.exit: ; preds = %test1.exit
105  br i1 undef, label %if.end150, label %for.body137.lr.ph
106
107for.body137.lr.ph:                                ; preds = %test1a.exit
108  br label %for.body137
109
110for.body137:                                      ; preds = %test1b.exit, %for.body137.lr.ph
111  %ShndxTable.0309 = phi %type1* [ %1, %for.body137.lr.ph ], [ %incdec.ptr, %test1b.exit ]
112  %ret.0..sroa_cast.i.i106 = bitcast %type1* %ShndxTable.0309 to i32*
113  br i1 undef, label %for.body137.if.end146_crit_edge, label %if.then140
114
115for.body137.if.end146_crit_edge:                  ; preds = %for.body137
116  %incdec.ptr = getelementptr inbounds %type1* %ShndxTable.0309, i64 1
117  br i1 undef, label %cond.false.i70, label %cond.end.i
118
119if.then140:                                       ; preds = %for.body137
120  %ret.0.copyload.i.i102 = load i32* %ret.0..sroa_cast.i.i106, align 2
121
122; CHECK: load {{.*}} align 2
123
124  unreachable
125
126cond.false.i70:                                   ; preds = %for.body137.if.end146_crit_edge
127  unreachable
128
129cond.end.i:                                       ; preds = %for.body137.if.end146_crit_edge
130  br i1 undef, label %test1b.exit, label %cond.false.i.i
131
132cond.false.i.i:                                   ; preds = %cond.end.i
133  unreachable
134
135test1b.exit: ; preds = %cond.end.i
136  br i1 undef, label %if.end150, label %for.body137
137
138if.end150:                                        ; preds = %test1b.exit, %test1a.exit, %if.then126, %if.end123
139  br i1 undef, label %for.end176, label %for.body155.lr.ph
140
141for.body155.lr.ph:                                ; preds = %if.end150
142  unreachable
143
144for.end176:                                       ; preds = %if.end150
145  unreachable
146
147return:                                           ; preds = %if.end
148  ret void
149}
150
151attributes #0 = { nounwind }
152attributes #1 = { nounwind readnone }
153attributes #2 = { nounwind uwtable }
154
155