blob: 2c8c9a5ec932fce84d9b2cd736ec885939f3ef57 [file] [log] [blame]
Tom Stellard2b971eb2013-05-10 02:09:45 +00001; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
2
Tom Stellard79243d92014-10-01 17:15:17 +00003; CHECK: {{^}}bfe_def:
Tom Stellard2b971eb2013-05-10 02:09:45 +00004; CHECK: BFE_UINT
Matt Arsenault3dbeefa2017-03-21 21:39:51 +00005define amdgpu_kernel void @bfe_def(i32 addrspace(1)* %out, i32 %x) {
Tom Stellard2b971eb2013-05-10 02:09:45 +00006entry:
7 %0 = lshr i32 %x, 5
8 %1 = and i32 %0, 15 ; 0xf
9 store i32 %1, i32 addrspace(1)* %out
10 ret void
11}
12
13; This program could be implemented using a BFE_UINT instruction, however
14; since the lshr constant + number of bits in the mask is >= 32, it can also be
15; implmented with a LSHR instruction, which is better, because LSHR has less
16; operands and requires less constants.
17
Tom Stellard79243d92014-10-01 17:15:17 +000018; CHECK: {{^}}bfe_shift:
Tom Stellard2b971eb2013-05-10 02:09:45 +000019; CHECK-NOT: BFE_UINT
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000020define amdgpu_kernel void @bfe_shift(i32 addrspace(1)* %out, i32 %x) {
Tom Stellard2b971eb2013-05-10 02:09:45 +000021entry:
22 %0 = lshr i32 %x, 16
23 %1 = and i32 %0, 65535 ; 0xffff
24 store i32 %1, i32 addrspace(1)* %out
25 ret void
26}