[PATCH] D136432: [AMDGPU] Combine BFI instructions.

Thomas Symalla via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 01:50:47 PDT 2022


tsymalla created this revision.
tsymalla added a reviewer: nhaehnle.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
tsymalla requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

When translating multiple bitfieldInserts where one
bitfieldInsert is the base for another one, the current
mechanism of creating XOR, AND, XOR sequences in the
frontend and having them lowered in ISel is not sufficient,
as the information about the bitmasks is lost during InstCombine.
This leads to only one v_bfi instruction being generated.

When creating the canonical bitfieldInsert pattern directly in the
frontend, the constants will still be partially merged by 
SimplifyDemandedBits, leading to a simplified pattern, however, the 
original sequence can be reconstructed and the nested bitfieldInserts 
can be generated.

In general, this approach tries to match sequences such as

(X1 & C1 <https://reviews.llvm.org/C1>) | (((X2 & C2) | (X3 & (~C1 <https://reviews.llvm.org/C1> | ~C3))))

and checks if this pattern is derived from

(X1 & C1 <https://reviews.llvm.org/C1>) | (~C1 <https://reviews.llvm.org/C1> & ((X2 & C2) | (X3 & ~C3)))

by looking at the constants and checking if they are disjoint and 
partitioning -1.

In such cases, it will try to generate the appropriate v_bfi instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136432

Files:
  llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
  llvm/test/CodeGen/AMDGPU/bfi_nested.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136432.469509.patch
Type: text/x-patch
Size: 6302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221021/82aac524/attachment-0001.bin>


More information about the llvm-commits mailing list