1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 -O0 < %s \
3; RUN:    | FileCheck -check-prefix=NOOPT %s
4; RUN: llc -relocation-model=static -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
5; RUN:     -mcpu=pwr8 < %s | FileCheck -check-prefix=STATIC %s
6
7;; Test loading and storing a common symbol for static relocation model.
8
9@comm_glob = common dso_local global i32 0, align 4
10
11define dso_local signext i32 @test_comm() nounwind {
12; NOOPT-LABEL: test_comm:
13; NOOPT:       # %bb.0: # %entry
14; NOOPT-NEXT:    addis 3, 2, comm_glob@toc@ha
15; NOOPT-NEXT:    addi 3, 3, comm_glob@toc@l
16; NOOPT-NEXT:    lwz 3, 0(3)
17; NOOPT-NEXT:    addi 4, 3, 1
18; NOOPT-NEXT:    addis 5, 2, comm_glob@toc@ha
19; NOOPT-NEXT:    addi 5, 5, comm_glob@toc@l
20; NOOPT-NEXT:    stw 4, 0(5)
21; NOOPT-NEXT:    extsw 3, 3
22; NOOPT-NEXT:    blr
23;
24; STATIC-LABEL: test_comm:
25; STATIC:       # %bb.0: # %entry
26; STATIC-NEXT:    addis 4, 2, comm_glob@toc@ha
27; STATIC-NEXT:    lwa 3, comm_glob@toc@l(4)
28; STATIC-NEXT:    addi 5, 3, 1
29; STATIC-NEXT:    stw 5, comm_glob@toc@l(4)
30; STATIC-NEXT:    blr
31entry:
32  %0 = load i32, i32* @comm_glob, align 4
33  %inc = add nsw i32 %0, 1
34  store i32 %inc, i32* @comm_glob, align 4
35  ret i32 %0
36}
37