1; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s
2
3; Check that the CodeGenPrepare Pass
4; does not wrongly rewrite the address computed by Instruction %4
5; as [12 + Base:%this].
6
7; This test makes sure that:
8; - both the store and the first load instructions
9;   within basic block labeled 'if.then' are not removed.
10; - the store instruction stores a value at address [60 + %this]
11; - the first load instruction loads a value at address [12 + %this]
12
13%class.A = type { %struct.B }
14%struct.B = type { %class.C, %class.D, %class.C, %class.D }
15%class.C = type { float, float, float }
16%class.D = type { [3 x %class.C] }
17
18define linkonce_odr void @foo(%class.A* nocapture %this, i32 %BoolValue) nounwind uwtable {
19entry:
20  %cmp = icmp eq i32 %BoolValue, 0
21  %address1 = getelementptr inbounds %class.A* %this, i64 0, i32 0, i32 3
22  %address2 = getelementptr inbounds %class.A* %this, i64 0, i32 0, i32 1
23  br i1 %cmp, label %if.else, label %if.then
24
25if.then:                                         ; preds = %entry
26  %0 = getelementptr inbounds %class.D* %address2, i64 0, i32 0, i64 0, i32 0
27  %1 = load float* %0, align 4
28  %2 = getelementptr inbounds float* %0, i64 3
29  %3 = load float* %2, align 4
30  %4 = getelementptr inbounds %class.D* %address1, i64 0, i32 0, i64 0, i32 0
31  store float %1, float* %4, align 4
32  br label %if.end
33
34if.else:                                          ; preds = %entry
35  br label %if.end
36
37if.end:                                           ; preds = %if.then, %if.else, %entry
38  ret void
39}
40
41; CHECK-LABEL: foo:
42; CHECK: movss 12([[THIS:%[a-zA-Z0-9]+]]), [[REGISTER:%[a-zA-Z0-9]+]]
43; CHECK-NEXT: movss [[REGISTER]], 60([[THIS]])
44
45