xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/bfe_uint.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK: {{^}}bfe_def:
4*9880d681SAndroid Build Coastguard Worker; CHECK: BFE_UINT
5*9880d681SAndroid Build Coastguard Workerdefine void @bfe_def(i32 addrspace(1)* %out, i32 %x) {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  %0 = lshr i32 %x, 5
8*9880d681SAndroid Build Coastguard Worker  %1 = and i32 %0, 15 ; 0xf
9*9880d681SAndroid Build Coastguard Worker  store i32 %1, i32 addrspace(1)* %out
10*9880d681SAndroid Build Coastguard Worker  ret void
11*9880d681SAndroid Build Coastguard Worker}
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker; This program could be implemented using a BFE_UINT instruction, however
14*9880d681SAndroid Build Coastguard Worker; since the lshr constant + number of bits in the mask is >= 32, it can also be
15*9880d681SAndroid Build Coastguard Worker; implmented with a LSHR instruction, which is better, because LSHR has less
16*9880d681SAndroid Build Coastguard Worker; operands and requires less constants.
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; CHECK: {{^}}bfe_shift:
19*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: BFE_UINT
20*9880d681SAndroid Build Coastguard Workerdefine void @bfe_shift(i32 addrspace(1)* %out, i32 %x) {
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker  %0 = lshr i32 %x, 16
23*9880d681SAndroid Build Coastguard Worker  %1 = and i32 %0, 65535 ; 0xffff
24*9880d681SAndroid Build Coastguard Worker  store i32 %1, i32 addrspace(1)* %out
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27