1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep 'call.*llvm.bswap' | wc -l | grep 5
uint %test1(uint %i) {
%tmp1 = shr uint %i, ubyte 24 ; <uint> [#uses=1]
%tmp3 = shr uint %i, ubyte 8 ; <uint> [#uses=1]
%tmp4 = and uint %tmp3, 65280 ; <uint> [#uses=1]
%tmp5 = or uint %tmp1, %tmp4 ; <uint> [#uses=1]
%tmp7 = shl uint %i, ubyte 8 ; <uint> [#uses=1]
%tmp8 = and uint %tmp7, 16711680 ; <uint> [#uses=1]
%tmp9 = or uint %tmp5, %tmp8 ; <uint> [#uses=1]
%tmp11 = shl uint %i, ubyte 24 ; <uint> [#uses=1]
%tmp12 = or uint %tmp9, %tmp11 ; <uint> [#uses=1]
ret uint %tmp12
}
uint %test2(uint %arg) {
%tmp2 = shl uint %arg, ubyte 24 ; <uint> [#uses=1]
%tmp4 = shl uint %arg, ubyte 8 ; <uint> [#uses=1]
%tmp5 = and uint %tmp4, 16711680 ; <uint> [#uses=1]
%tmp6 = or uint %tmp2, %tmp5 ; <uint> [#uses=1]
%tmp8 = shr uint %arg, ubyte 8 ; <uint> [#uses=1]
%tmp9 = and uint %tmp8, 65280 ; <uint> [#uses=1]
%tmp10 = or uint %tmp6, %tmp9 ; <uint> [#uses=1]
%tmp12 = shr uint %arg, ubyte 24 ; <uint> [#uses=1]
%tmp14 = or uint %tmp10, %tmp12 ; <uint> [#uses=1]
ret uint %tmp14
}
ushort %test3(ushort %s) {
%tmp2 = shr ushort %s, ubyte 8
%tmp4 = shl ushort %s, ubyte 8
%tmp5 = or ushort %tmp2, %tmp4
ret ushort %tmp5
}
ushort %test4(ushort %s) {
%tmp2 = shr ushort %s, ubyte 8
%tmp4 = shl ushort %s, ubyte 8
%tmp5 = or ushort %tmp4, %tmp2
ret ushort %tmp5
}
; unsigned short test5(unsigned short a) {
; return ((a & 0xff00) >> 8 | (a & 0x00ff) << 8);
;}
ushort %test5(ushort %a) {
%tmp = zext ushort %a to int
%tmp1 = and int %tmp, 65280
%tmp2 = ashr int %tmp1, ubyte 8
%tmp2 = trunc int %tmp2 to short
%tmp3 = zext ushort %a to int
%tmp4 = and int %tmp3, 255
%tmp5 = shl int %tmp4, ubyte 8
%tmp5 = trunc int %tmp5 to short
%tmp = or short %tmp2, %tmp5
%tmp6 = bitcast short %tmp to ushort
%tmp6 = zext ushort %tmp6 to int
%retval = trunc int %tmp6 to ushort
ret ushort %retval
}
|