xref: /llvm-project/llvm/test/CodeGen/X86/codegen-prepare.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
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(ptr nocapture %this, i32 %BoolValue) nounwind uwtable {
19entry:
20  %cmp = icmp eq i32 %BoolValue, 0
21  %address1 = getelementptr inbounds %class.A, ptr %this, i64 0, i32 0, i32 3
22  %address2 = getelementptr inbounds %class.A, ptr %this, i64 0, i32 0, i32 1
23  br i1 %cmp, label %if.else, label %if.then
24
25if.then:                                         ; preds = %entry
26  %0 = load float, ptr %address2, align 4
27  %1 = getelementptr inbounds float, ptr %address2, i64 3
28  %2 = load float, ptr %1, align 4
29  store float %0, ptr %address1, align 4
30  br label %if.end
31
32if.else:                                          ; preds = %entry
33  br label %if.end
34
35if.end:                                           ; preds = %if.then, %if.else, %entry
36  ret void
37}
38
39; CHECK-LABEL: foo:
40; CHECK: movss 12([[THIS:%[a-zA-Z0-9]+]]), [[REGISTER:%[a-zA-Z0-9]+]]
41; CHECK-NEXT: movss [[REGISTER]], 60([[THIS]])
42
43