OSDN Git Service

[AMDGPU] Shrink scalar AND, OR, XOR instructions
authorGraham Sellers <graham.sellers@amd.com>
Fri, 7 Dec 2018 15:33:21 +0000 (15:33 +0000)
committerGraham Sellers <graham.sellers@amd.com>
Fri, 7 Dec 2018 15:33:21 +0000 (15:33 +0000)
commit7e8f37b605ddd1ce671b52e40b294dfda5090e43
tree09cbb11758284ff383686699233bb58e2e7615b9
parente3677c90c664ce5b1d88c81676833a1b2553924a
[AMDGPU] Shrink scalar AND, OR, XOR instructions

This change attempts to shrink scalar AND, OR and XOR instructions which take an immediate that isn't inlineable.

It performs:
AND s0, s0, ~(1 << n) -> BITSET0 s0, n
OR s0, s0, (1 << n) -> BITSET1 s0, n
AND s0, s1, x -> ANDN2 s0, s1, ~x
OR s0, s1, x -> ORN2 s0, s1, ~x
XOR s0, s1, x -> XNOR s0, s1, ~x

In particular, this catches setting and clearing the sign bit for fabs (and x, 0x7ffffffff -> bitset0 x, 31 and or x, 0x80000000 -> bitset1 x, 31).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348601 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AMDGPU/SIShrinkInstructions.cpp
test/CodeGen/AMDGPU/andorbitset.ll [new file with mode: 0644]
test/CodeGen/AMDGPU/andorxorinvimm.ll [new file with mode: 0644]
test/CodeGen/AMDGPU/fabs.ll
test/CodeGen/AMDGPU/fneg-fabs.ll
test/CodeGen/AMDGPU/gep-address-space.ll
test/CodeGen/AMDGPU/local-64.ll