summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/rotate.ll
blob: fb04be96d6ff563b5dd87d5ceaa589b152e8f27d (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 -x86-asm-syntax=intel | \
; RUN:   grep {ro\[rl\]} | wc -l | grep 12

uint %rotl32(uint %A, ubyte %Amt) {
	%B = shl uint %A, ubyte %Amt
	%Amt2 = sub ubyte 32, %Amt
	%C = shr uint %A, ubyte %Amt2
	%D = or uint %B, %C
	ret uint %D
}

uint %rotr32(uint %A, ubyte %Amt) {
	%B = shr uint %A, ubyte %Amt
	%Amt2 = sub ubyte 32, %Amt
	%C = shl uint %A, ubyte %Amt2
	%D = or uint %B, %C
	ret uint %D
}

uint %rotli32(uint %A) {
	%B = shl uint %A, ubyte 5
	%C = shr uint %A, ubyte 27
	%D = or uint %B, %C
	ret uint %D
}

uint %rotri32(uint %A) {
	%B = shr uint %A, ubyte 5
	%C = shl uint %A, ubyte 27
	%D = or uint %B, %C
	ret uint %D
}

ushort %rotl16(ushort %A, ubyte %Amt) {
	%B = shl ushort %A, ubyte %Amt
	%Amt2 = sub ubyte 16, %Amt
	%C = shr ushort %A, ubyte %Amt2
	%D = or ushort %B, %C
	ret ushort %D
}

ushort %rotr16(ushort %A, ubyte %Amt) {
	%B = shr ushort %A, ubyte %Amt
	%Amt2 = sub ubyte 16, %Amt
	%C = shl ushort %A, ubyte %Amt2
	%D = or ushort %B, %C
	ret ushort %D
}

ushort %rotli16(ushort %A) {
	%B = shl ushort %A, ubyte 5
	%C = shr ushort %A, ubyte 11
	%D = or ushort %B, %C
	ret ushort %D
}

ushort %rotri16(ushort %A) {
	%B = shr ushort %A, ubyte 5
	%C = shl ushort %A, ubyte 11
	%D = or ushort %B, %C
	ret ushort %D
}

ubyte %rotl8(ubyte %A, ubyte %Amt) {
	%B = shl ubyte %A, ubyte %Amt
	%Amt2 = sub ubyte 8, %Amt
	%C = shr ubyte %A, ubyte %Amt2
	%D = or ubyte %B, %C
	ret ubyte %D
}

ubyte %rotr8(ubyte %A, ubyte %Amt) {
	%B = shr ubyte %A, ubyte %Amt
	%Amt2 = sub ubyte 8, %Amt
	%C = shl ubyte %A, ubyte %Amt2
	%D = or ubyte %B, %C
	ret ubyte %D
}

ubyte %rotli8(ubyte %A) {
	%B = shl ubyte %A, ubyte 5
	%C = shr ubyte %A, ubyte 3
	%D = or ubyte %B, %C
	ret ubyte %D
}

ubyte %rotri8(ubyte %A) {
	%B = shr ubyte %A, ubyte 5
	%C = shl ubyte %A, ubyte 3
	%D = or ubyte %B, %C
	ret ubyte %D
}