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
8 define void @STWBRX(i32 %i, i8* %ptr, i32 %off) {
11 ; X32-NEXT: stwbrx r3, r4, r5
16 ; X64-NEXT: extsw r5, r5
17 ; X64-NEXT: stwbrx r3, r4, r5
20 ; PWR7_64-LABEL: STWBRX:
22 ; PWR7_64-NEXT: extsw r5, r5
23 ; PWR7_64-NEXT: stwbrx r3, r4, r5
25 %tmp1 = getelementptr i8, i8* %ptr, i32 %off
26 %tmp1.upgrd.1 = bitcast i8* %tmp1 to i32*
27 %tmp13 = tail call i32 @llvm.bswap.i32( i32 %i )
28 store i32 %tmp13, i32* %tmp1.upgrd.1
32 define i32 @LWBRX(i8* %ptr, i32 %off) {
35 ; X32-NEXT: lwbrx r3, r3, r4
40 ; X64-NEXT: extsw r4, r4
41 ; X64-NEXT: lwbrx r3, r3, r4
44 ; PWR7_64-LABEL: LWBRX:
46 ; PWR7_64-NEXT: extsw r4, r4
47 ; PWR7_64-NEXT: lwbrx r3, r3, r4
49 %tmp1 = getelementptr i8, i8* %ptr, i32 %off
50 %tmp1.upgrd.2 = bitcast i8* %tmp1 to i32*
51 %tmp = load i32, i32* %tmp1.upgrd.2
52 %tmp14 = tail call i32 @llvm.bswap.i32( i32 %tmp )
56 define void @STHBRX(i16 %s, i8* %ptr, i32 %off) {
59 ; X32-NEXT: sthbrx r3, r4, r5
64 ; X64-NEXT: extsw r5, r5
65 ; X64-NEXT: sthbrx r3, r4, r5
68 ; PWR7_64-LABEL: STHBRX:
70 ; PWR7_64-NEXT: extsw r5, r5
71 ; PWR7_64-NEXT: sthbrx r3, r4, r5
73 %tmp1 = getelementptr i8, i8* %ptr, i32 %off
74 %tmp1.upgrd.3 = bitcast i8* %tmp1 to i16*
75 %tmp5 = call i16 @llvm.bswap.i16( i16 %s )
76 store i16 %tmp5, i16* %tmp1.upgrd.3
80 define i16 @LHBRX(i8* %ptr, i32 %off) {
83 ; X32-NEXT: lhbrx r3, r3, r4
88 ; X64-NEXT: extsw r4, r4
89 ; X64-NEXT: lhbrx r3, r3, r4
92 ; PWR7_64-LABEL: LHBRX:
94 ; PWR7_64-NEXT: extsw r4, r4
95 ; PWR7_64-NEXT: lhbrx r3, r3, r4
97 %tmp1 = getelementptr i8, i8* %ptr, i32 %off
98 %tmp1.upgrd.4 = bitcast i8* %tmp1 to i16*
99 %tmp = load i16, i16* %tmp1.upgrd.4
100 %tmp6 = call i16 @llvm.bswap.i16( i16 %tmp )
104 ; TODO: combine the bswap feeding a store on subtargets
105 ; that do not have an STDBRX.
106 define void @STDBRX(i64 %i, i8* %ptr, i64 %off) {
107 ; PWR7_32-LABEL: STDBRX:
109 ; PWR7_32-NEXT: li r6, 4
110 ; PWR7_32-NEXT: add r7, r5, r8
111 ; PWR7_32-NEXT: stwbrx r4, r5, r8
112 ; PWR7_32-NEXT: stwbrx r3, r7, r6
117 ; X64-NEXT: rotldi r6, r3, 16
118 ; X64-NEXT: rotldi r7, r3, 8
119 ; X64-NEXT: rldimi r7, r6, 8, 48
120 ; X64-NEXT: rotldi r6, r3, 24
121 ; X64-NEXT: rldimi r7, r6, 16, 40
122 ; X64-NEXT: rotldi r6, r3, 32
123 ; X64-NEXT: rldimi r7, r6, 24, 32
124 ; X64-NEXT: rotldi r6, r3, 48
125 ; X64-NEXT: rldimi r7, r6, 40, 16
126 ; X64-NEXT: rotldi r6, r3, 56
127 ; X64-NEXT: rldimi r7, r6, 48, 8
128 ; X64-NEXT: rldimi r7, r3, 56, 0
129 ; X64-NEXT: stdx r7, r4, r5
132 ; PWR7_64-LABEL: STDBRX:
134 ; PWR7_64-NEXT: stdbrx r3, r4, r5
136 %tmp1 = getelementptr i8, i8* %ptr, i64 %off
137 %tmp1.upgrd.1 = bitcast i8* %tmp1 to i64*
138 %tmp13 = tail call i64 @llvm.bswap.i64( i64 %i )
139 store i64 %tmp13, i64* %tmp1.upgrd.1
143 define i64 @LDBRX(i8* %ptr, i64 %off) {
144 ; PWR7_32-LABEL: LDBRX:
146 ; PWR7_32-NEXT: li r5, 4
147 ; PWR7_32-NEXT: add r7, r3, r6
148 ; PWR7_32-NEXT: lwbrx r4, r3, r6
149 ; PWR7_32-NEXT: lwbrx r3, r7, r5
155 ; X64-NEXT: lwbrx r5, r3, r4
156 ; X64-NEXT: add r3, r3, r4
157 ; X64-NEXT: lwbrx r3, r3, r6
158 ; X64-NEXT: rldimi r5, r3, 32, 0
159 ; X64-NEXT: mr r3, r5
162 ; PWR7_64-LABEL: LDBRX:
164 ; PWR7_64-NEXT: ldbrx r3, r3, r4
166 %tmp1 = getelementptr i8, i8* %ptr, i64 %off
167 %tmp1.upgrd.2 = bitcast i8* %tmp1 to i64*
168 %tmp = load i64, i64* %tmp1.upgrd.2
169 %tmp14 = tail call i64 @llvm.bswap.i64( i64 %tmp )
173 declare i16 @llvm.bswap.i16(i16)
174 declare i32 @llvm.bswap.i32(i32)
175 declare i64 @llvm.bswap.i64(i64)