1 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -O0 -code-model=medium <%s | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -O0 -code-model=large <%s | FileCheck %s
4 ; Test correct code generation for medium and large code model
5 ; for loading and storing an external variable.
7 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
8 target triple = "powerpc64-unknown-linux-gnu"
12 @ei = external global i32
13 @fi = global i32 0, align 4, comdat($fi)
14 @gi = global i32 0, align 4, comdat($fi)
16 define signext i32 @test_external() nounwind {
18 %0 = load i32, ptr @ei, align 4
19 %inc = add nsw i32 %0, 1
20 store i32 %inc, ptr @ei, align 4
26 %0 = load i32, ptr @gi, align 4
27 %1 = load i32, ptr @fi, align 4
32 ; CHECK-LABEL: test_external:
33 ; CHECK: addis [[REG1:[0-9]+]], 2, .LC[[TOCNUM:[0-9]+]]@toc@ha
34 ; CHECK: ld [[REG2:[0-9]+]], .LC[[TOCNUM]]@toc@l([[REG1]])
35 ; CHECK: lwz {{[0-9]+}}, 0([[REG2]])
36 ; CHECK: addis [[REG3:[0-9]+]], 2, .LC[[TOCNUM]]@toc@ha
37 ; CHECK: ld [[REG4:[0-9]+]], .LC[[TOCNUM]]@toc@l([[REG3]])
38 ; CHECK: stw {{[0-9]+}}, 0([[REG4]])
41 ; CHECK: .section .toc,"aw",@progbits
43 ; CHECK-NEXT: .tc ei[TC],ei
45 ; CHECK-NEXT: .tc gi[TC],gi
47 ; CHECK-NEXT: .tc fi[TC],fi