Add 32 bit and reg-imm and disable invalid patterns for now
[oota-llvm.git] / test / CodeGen / PowerPC / bswap-load-store.ll
1 ; RUN: llvm-as < %s | llc -march=ppc32 | \
2 ; RUN:   grep {stwbrx\\|lwbrx\\|sthbrx\\|lhbrx} | count 4
3 ; RUN: llvm-as < %s | llc -march=ppc32 | not grep rlwinm
4 ; RUN: llvm-as < %s | llc -march=ppc32 | not grep rlwimi
5 ; RUN: llvm-as < %s | llc -march=ppc64 | \
6 ; RUN:   grep {stwbrx\\|lwbrx\\|sthbrx\\|lhbrx} | count 4
7 ; RUN: llvm-as < %s | llc -march=ppc64 | not grep rlwinm
8 ; RUN: llvm-as < %s | llc -march=ppc64 | not grep rlwimi
9
10 define void @STWBRX(i32 %i, i8* %ptr, i32 %off) {
11         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
12         %tmp1.upgrd.1 = bitcast i8* %tmp1 to i32*               ; <i32*> [#uses=1]
13         %tmp13 = tail call i32 @llvm.bswap.i32( i32 %i )                ; <i32> [#uses=1]
14         store i32 %tmp13, i32* %tmp1.upgrd.1
15         ret void
16 }
17
18 define i32 @LWBRX(i8* %ptr, i32 %off) {
19         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
20         %tmp1.upgrd.2 = bitcast i8* %tmp1 to i32*               ; <i32*> [#uses=1]
21         %tmp = load i32* %tmp1.upgrd.2          ; <i32> [#uses=1]
22         %tmp14 = tail call i32 @llvm.bswap.i32( i32 %tmp )              ; <i32> [#uses=1]
23         ret i32 %tmp14
24 }
25
26 define void @STHBRX(i16 %s, i8* %ptr, i32 %off) {
27         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
28         %tmp1.upgrd.3 = bitcast i8* %tmp1 to i16*               ; <i16*> [#uses=1]
29         %tmp5 = call i16 @llvm.bswap.i16( i16 %s )              ; <i16> [#uses=1]
30         store i16 %tmp5, i16* %tmp1.upgrd.3
31         ret void
32 }
33
34 define i16 @LHBRX(i8* %ptr, i32 %off) {
35         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
36         %tmp1.upgrd.4 = bitcast i8* %tmp1 to i16*               ; <i16*> [#uses=1]
37         %tmp = load i16* %tmp1.upgrd.4          ; <i16> [#uses=1]
38         %tmp6 = call i16 @llvm.bswap.i16( i16 %tmp )            ; <i16> [#uses=1]
39         ret i16 %tmp6
40 }
41
42 declare i32 @llvm.bswap.i32(i32)
43
44 declare i16 @llvm.bswap.i16(i16)
45