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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s
; These tests just check that the plumbing is in place for @llvm.bitreverse. The
; actual output is massive at the moment as llvm.bitreverse is not yet legal.
declare <2 x i16> @llvm.bitreverse.v2i16(<2 x i16>) readnone
define <2 x i16> @test_bitreverse_v2i16(<2 x i16> %a) nounwind {
; CHECK-LABEL: test_bitreverse_v2i16:
; CHECK: # BB#0:
; CHECK-NEXT: movw {{[0-9]+}}(%esp), %cx
; CHECK-NEXT: movw {{[0-9]+}}(%esp), %ax
; CHECK-NEXT: rolw $8, %ax
; CHECK-NEXT: movl %eax, %edx
; CHECK-NEXT: andl $3855, %edx # imm = 0xF0F
; CHECK-NEXT: shll $4, %edx
; CHECK-NEXT: andl $61680, %eax # imm = 0xF0F0
; CHECK-NEXT: shrl $4, %eax
; CHECK-NEXT: orl %edx, %eax
; CHECK-NEXT: movl %eax, %edx
; CHECK-NEXT: andl $13107, %edx # imm = 0x3333
; CHECK-NEXT: andl $52428, %eax # imm = 0xCCCC
; CHECK-NEXT: shrl $2, %eax
; CHECK-NEXT: leal (%eax,%edx,4), %eax
; CHECK-NEXT: movl %eax, %edx
; CHECK-NEXT: andl $21845, %edx # imm = 0x5555
; CHECK-NEXT: andl $43690, %eax # imm = 0xAAAA
; CHECK-NEXT: shrl %eax
; CHECK-NEXT: leal (%eax,%edx,2), %eax
; CHECK-NEXT: rolw $8, %cx
; CHECK-NEXT: movl %ecx, %edx
; CHECK-NEXT: andl $3855, %edx # imm = 0xF0F
; CHECK-NEXT: shll $4, %edx
; CHECK-NEXT: andl $61680, %ecx # imm = 0xF0F0
; CHECK-NEXT: shrl $4, %ecx
; CHECK-NEXT: orl %edx, %ecx
; CHECK-NEXT: movl %ecx, %edx
; CHECK-NEXT: andl $13107, %edx # imm = 0x3333
; CHECK-NEXT: andl $52428, %ecx # imm = 0xCCCC
; CHECK-NEXT: shrl $2, %ecx
; CHECK-NEXT: leal (%ecx,%edx,4), %ecx
; CHECK-NEXT: movl %ecx, %edx
; CHECK-NEXT: andl $21845, %edx # imm = 0x5555
; CHECK-NEXT: andl $43690, %ecx # imm = 0xAAAA
; CHECK-NEXT: shrl %ecx
; CHECK-NEXT: leal (%ecx,%edx,2), %edx
; CHECK-NEXT: # kill: %AX<def> %AX<kill> %EAX<kill>
; CHECK-NEXT: # kill: %DX<def> %DX<kill> %EDX<kill>
; CHECK-NEXT: retl
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a)
ret <2 x i16> %b
}
declare i24 @llvm.bitreverse.i24(i24) readnone
define i24 @test_bitreverse_i24(i24 %a) nounwind {
; CHECK-LABEL: test_bitreverse_i24:
; CHECK: # BB#0:
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: bswapl %eax
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andl $252645135, %ecx # imm = 0xF0F0F0F
; CHECK-NEXT: shll $4, %ecx
; CHECK-NEXT: andl $-252645136, %eax # imm = 0xF0F0F0F0
; CHECK-NEXT: shrl $4, %eax
; CHECK-NEXT: orl %ecx, %eax
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andl $858993459, %ecx # imm = 0x33333333
; CHECK-NEXT: andl $-858993460, %eax # imm = 0xCCCCCCCC
; CHECK-NEXT: shrl $2, %eax
; CHECK-NEXT: leal (%eax,%ecx,4), %eax
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andl $1431655680, %ecx # imm = 0x55555500
; CHECK-NEXT: andl $-1431655936, %eax # imm = 0xAAAAAA00
; CHECK-NEXT: shrl %eax
; CHECK-NEXT: leal (%eax,%ecx,2), %eax
; CHECK-NEXT: shrl $8, %eax
; CHECK-NEXT: retl
%b = call i24 @llvm.bitreverse.i24(i24 %a)
ret i24 %b
}
declare i8 @llvm.bitreverse.i8(i8) readnone
define i8 @test_bitreverse_i8(i8 %a) {
; CHECK-LABEL: test_bitreverse_i8:
; CHECK: # BB#0:
; CHECK-NEXT: movb {{[0-9]+}}(%esp), %al
; CHECK-NEXT: rolb $4, %al
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andb $51, %cl
; CHECK-NEXT: shlb $2, %cl
; CHECK-NEXT: andb $-52, %al
; CHECK-NEXT: shrb $2, %al
; CHECK-NEXT: orb %cl, %al
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andb $85, %cl
; CHECK-NEXT: addb %cl, %cl
; CHECK-NEXT: andb $-86, %al
; CHECK-NEXT: shrb %al
; CHECK-NEXT: orb %cl, %al
; CHECK-NEXT: retl
%b = call i8 @llvm.bitreverse.i8(i8 %a)
ret i8 %b
}
declare i4 @llvm.bitreverse.i4(i4) readnone
define i4 @test_bitreverse_i4(i4 %a) {
; CHECK-LABEL: test_bitreverse_i4:
; CHECK: # BB#0:
; CHECK-NEXT: movb {{[0-9]+}}(%esp), %al
; CHECK-NEXT: rolb $4, %al
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andb $51, %cl
; CHECK-NEXT: shlb $2, %cl
; CHECK-NEXT: andb $-52, %al
; CHECK-NEXT: shrb $2, %al
; CHECK-NEXT: orb %cl, %al
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andb $80, %cl
; CHECK-NEXT: addb %cl, %cl
; CHECK-NEXT: andb $-96, %al
; CHECK-NEXT: shrb %al
; CHECK-NEXT: orb %cl, %al
; CHECK-NEXT: shrb $4, %al
; CHECK-NEXT: retl
%b = call i4 @llvm.bitreverse.i4(i4 %a)
ret i4 %b
}
; These tests check that bitreverse(constant) calls are folded
define <2 x i16> @fold_v2i16() {
; CHECK-LABEL: fold_v2i16:
; CHECK: # BB#0:
; CHECK-NEXT: movw $-4096, %ax # imm = 0xF000
; CHECK-NEXT: movw $240, %dx
; CHECK-NEXT: retl
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> <i16 15, i16 3840>)
ret <2 x i16> %b
}
define i24 @fold_i24() {
; CHECK-LABEL: fold_i24:
; CHECK: # BB#0:
; CHECK-NEXT: movl $2048, %eax # imm = 0x800
; CHECK-NEXT: retl
%b = call i24 @llvm.bitreverse.i24(i24 4096)
ret i24 %b
}
define i8 @fold_i8() {
; CHECK-LABEL: fold_i8:
; CHECK: # BB#0:
; CHECK-NEXT: movb $-16, %al
; CHECK-NEXT: retl
%b = call i8 @llvm.bitreverse.i8(i8 15)
ret i8 %b
}
define i4 @fold_i4() {
; CHECK-LABEL: fold_i4:
; CHECK: # BB#0:
; CHECK-NEXT: movb $1, %al
; CHECK-NEXT: retl
%b = call i4 @llvm.bitreverse.i4(i4 8)
ret i4 %b
}
; These tests check that bitreverse(bitreverse()) calls are removed
define i8 @identity_i8(i8 %a) {
; CHECK-LABEL: identity_i8:
; CHECK: # BB#0:
; CHECK-NEXT: movb {{[0-9]+}}(%esp), %al
; CHECK-NEXT: retl
%b = call i8 @llvm.bitreverse.i8(i8 %a)
%c = call i8 @llvm.bitreverse.i8(i8 %b)
ret i8 %c
}
define <2 x i16> @identity_v2i16(<2 x i16> %a) {
; CHECK-LABEL: identity_v2i16:
; CHECK: # BB#0:
; CHECK-NEXT: movzwl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movzwl {{[0-9]+}}(%esp), %edx
; CHECK-NEXT: retl
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a)
%c = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %b)
ret <2 x i16> %c
}
; These tests check that bitreverse(undef) calls are removed
define i8 @undef_i8() {
; CHECK-LABEL: undef_i8:
; CHECK: # BB#0:
; CHECK-NEXT: retl
%b = call i8 @llvm.bitreverse.i8(i8 undef)
ret i8 %b
}
define <2 x i16> @undef_v2i16() {
; CHECK-LABEL: undef_v2i16:
; CHECK: # BB#0:
; CHECK-NEXT: retl
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> undef)
ret <2 x i16> %b
}
|