OSDN Git Service

[AMDGPU] Combine and (srl) into shl (bfe)
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Tue, 23 May 2017 19:54:48 +0000 (19:54 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Tue, 23 May 2017 19:54:48 +0000 (19:54 +0000)
commit6ff1a723f7396bbb93385d08491032323de658f3
tree629d34191a46961c2913900b0f6538ca6af48e5b
parentbcb35301da44beedd9505dd4d4afcd5f6c35ac04
[AMDGPU] Combine and (srl) into shl (bfe)

Perform DAG combine:
and (srl x, c), mask => shl (bfe x, nb + c, mask >> nb), nb
Where nb is a number of trailing zeroes in mask.

It replaces two instructions with two and BFE is generally a more
expensive one. However this is only done if we are selecting a byte
or word at an aligned boundary which results in a proper SDWA
operand pattern. It is only done if SDWA is supported.

TODO: improve SDWA pass to actually convert this pattern. It is not
done now because we have an immediate in the instruction, which has
be moved into a VGPR.

Differential Revision: https://reviews.llvm.org/D33455

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303681 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
lib/Target/AMDGPU/AMDGPUSubtarget.h
lib/Target/AMDGPU/SIISelLowering.cpp
test/CodeGen/AMDGPU/bfe-combine.ll [new file with mode: 0644]