1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs < %s -mtriple=ppc32-- -mcpu=ppc32 | FileCheck %s --check-prefixes=X32
3 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs < %s -mtriple=ppc32-- -mcpu=pwr7 | FileCheck %s --check-prefixes=X32,PWR7_32
4 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs < %s -mtriple=powerpc64-- -mcpu=ppc64 | FileCheck %s --check-prefixes=X64
5 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs < %s -mtriple=powerpc64-- -mcpu=pwr7 | FileCheck %s --check-prefixes=PWR7_64
6 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs < %s -mtriple=powerpc64-- -mcpu=a2 | FileCheck %s --check-prefixes=A2_64
9 define void @STWBRX(i32 %i, ptr %ptr, i32 %off) {
12 ; X32-NEXT: stwbrx r3, r4, r5
17 ; X64-NEXT: extsw r5, r5
18 ; X64-NEXT: stwbrx r3, r4, r5
21 ; PWR7_64-LABEL: STWBRX:
23 ; PWR7_64-NEXT: extsw r5, r5
24 ; PWR7_64-NEXT: stwbrx r3, r4, r5
27 ; A2_64-LABEL: STWBRX:
29 ; A2_64-NEXT: extsw r5, r5
30 ; A2_64-NEXT: stwbrx r3, r4, r5
32 %tmp1 = getelementptr i8, ptr %ptr, i32 %off
33 %tmp13 = tail call i32 @llvm.bswap.i32( i32 %i )
34 store i32 %tmp13, ptr %tmp1
38 define i32 @LWBRX(ptr %ptr, i32 %off) {
41 ; X32-NEXT: lwbrx r3, r3, r4
46 ; X64-NEXT: extsw r4, r4
47 ; X64-NEXT: lwbrx r3, r3, r4
50 ; PWR7_64-LABEL: LWBRX:
52 ; PWR7_64-NEXT: extsw r4, r4
53 ; PWR7_64-NEXT: lwbrx r3, r3, r4
58 ; A2_64-NEXT: extsw r4, r4
59 ; A2_64-NEXT: lwbrx r3, r3, r4
61 %tmp1 = getelementptr i8, ptr %ptr, i32 %off
62 %tmp = load i32, ptr %tmp1
63 %tmp14 = tail call i32 @llvm.bswap.i32( i32 %tmp )
67 define void @STHBRX(i16 %s, ptr %ptr, i32 %off) {
70 ; X32-NEXT: sthbrx r3, r4, r5
75 ; X64-NEXT: extsw r5, r5
76 ; X64-NEXT: sthbrx r3, r4, r5
79 ; PWR7_64-LABEL: STHBRX:
81 ; PWR7_64-NEXT: extsw r5, r5
82 ; PWR7_64-NEXT: sthbrx r3, r4, r5
85 ; A2_64-LABEL: STHBRX:
87 ; A2_64-NEXT: extsw r5, r5
88 ; A2_64-NEXT: sthbrx r3, r4, r5
90 %tmp1 = getelementptr i8, ptr %ptr, i32 %off
91 %tmp5 = call i16 @llvm.bswap.i16( i16 %s )
92 store i16 %tmp5, ptr %tmp1
96 define i16 @LHBRX(ptr %ptr, i32 %off) {
99 ; X32-NEXT: lhbrx r3, r3, r4
104 ; X64-NEXT: extsw r4, r4
105 ; X64-NEXT: lhbrx r3, r3, r4
108 ; PWR7_64-LABEL: LHBRX:
110 ; PWR7_64-NEXT: extsw r4, r4
111 ; PWR7_64-NEXT: lhbrx r3, r3, r4
114 ; A2_64-LABEL: LHBRX:
116 ; A2_64-NEXT: extsw r4, r4
117 ; A2_64-NEXT: lhbrx r3, r3, r4
119 %tmp1 = getelementptr i8, ptr %ptr, i32 %off
120 %tmp = load i16, ptr %tmp1
121 %tmp6 = call i16 @llvm.bswap.i16( i16 %tmp )
125 ; TODO: combine the bswap feeding a store on subtargets
126 ; that do not have an STDBRX.
127 define void @STDBRX(i64 %i, ptr %ptr, i64 %off) {
128 ; PWR7_32-LABEL: STDBRX:
130 ; PWR7_32-NEXT: add r6, r5, r8
131 ; PWR7_32-NEXT: stwbrx r4, r5, r8
132 ; PWR7_32-NEXT: li r4, 4
133 ; PWR7_32-NEXT: stwbrx r3, r6, r4
138 ; X64-NEXT: rotldi r6, r3, 16
139 ; X64-NEXT: rotldi r7, r3, 8
140 ; X64-NEXT: rldimi r7, r6, 8, 48
141 ; X64-NEXT: rotldi r6, r3, 24
142 ; X64-NEXT: rldimi r7, r6, 16, 40
143 ; X64-NEXT: rotldi r6, r3, 32
144 ; X64-NEXT: rldimi r7, r6, 24, 32
145 ; X64-NEXT: rotldi r6, r3, 48
146 ; X64-NEXT: rldimi r7, r6, 40, 16
147 ; X64-NEXT: rotldi r6, r3, 56
148 ; X64-NEXT: rldimi r7, r6, 48, 8
149 ; X64-NEXT: rldimi r7, r3, 56, 0
150 ; X64-NEXT: stdx r7, r4, r5
153 ; PWR7_64-LABEL: STDBRX:
155 ; PWR7_64-NEXT: stdbrx r3, r4, r5
158 ; A2_64-LABEL: STDBRX:
160 ; A2_64-NEXT: stdbrx r3, r4, r5
162 %tmp1 = getelementptr i8, ptr %ptr, i64 %off
163 %tmp13 = tail call i64 @llvm.bswap.i64( i64 %i )
164 store i64 %tmp13, ptr %tmp1
168 define i64 @LDBRX(ptr %ptr, i64 %off) {
169 ; PWR7_32-LABEL: LDBRX:
171 ; PWR7_32-NEXT: add r5, r3, r6
172 ; PWR7_32-NEXT: lwbrx r4, r3, r6
173 ; PWR7_32-NEXT: li r3, 4
174 ; PWR7_32-NEXT: lwbrx r3, r5, r3
180 ; X64-NEXT: lwbrx r5, r3, r4
181 ; X64-NEXT: add r3, r3, r4
182 ; X64-NEXT: lwbrx r3, r3, r6
183 ; X64-NEXT: rldimi r5, r3, 32, 0
184 ; X64-NEXT: mr r3, r5
187 ; PWR7_64-LABEL: LDBRX:
189 ; PWR7_64-NEXT: ldbrx r3, r3, r4
192 ; A2_64-LABEL: LDBRX:
194 ; A2_64-NEXT: ldbrx r3, r3, r4
196 %tmp1 = getelementptr i8, ptr %ptr, i64 %off
197 %tmp = load i64, ptr %tmp1
198 %tmp14 = tail call i64 @llvm.bswap.i64( i64 %tmp )
202 declare i16 @llvm.bswap.i16(i16)
203 declare i32 @llvm.bswap.i32(i32)
204 declare i64 @llvm.bswap.i64(i64)