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