[PATCH] D97063: [AMDGPU][SelectionDAG] Don't combine uniform multiplies to MUL_[UI]24

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 09:29:20 PST 2021


foad created this revision.
foad added reviewers: arsenm, rampitec, nhaehnle.
Herald added subscribers: ecnelises, kerbowa, jfb, arphaman, hiraditya, t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Prefer to keep uniform (non-divergent) multiplies on the scalar ALU when
possible. This significantly improves some game cases by eliminating
v_readfirstlane instructions when the result feeds into a scalar
operation, like the address calculation for a scalar load or store.

Since isDivergent is only an approximation of whether a value is in
SGPRs, it can potentially regress some situations where a uniform value
ends up in a VGPR. These should be rare in real code, although the test
changes do contain a number of examples.

Most of the test changes are just using s_mul instead of v_mul/mad which
is generally better for both register pressure and latency (at least on
GFX10 where sgpr pressure doesn't affect occupancy and vector ALU
instructions have significantly longer latency than scalar ALU). Some
R600 tests now use MULLO_INT instead of MUL_UINT24.

GlobalISel appears to handle more scenarios in the desirable way,
although it can also be thrown off and fails to select the 24-bit
multiplies in some cases.

Alternative solution considered and rejected was to allow selecting
MUL_[UI]24 to S_MUL_I32. I've rejected this because the definition of
those SD operations works is don't-care on the most significant 8 bits,
and this fact is used in some combines via SimplifyDemandedBits.

Based on a patch by Nicolai Hähnle.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97063

Files:
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_buffer.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_global_pointer.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_local_pointer.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_pixelshader.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_raw_buffer.ll
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_struct_buffer.ll
  llvm/test/CodeGen/AMDGPU/frame-index-elimination.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sendmsg.ll
  llvm/test/CodeGen/AMDGPU/llvm.r600.read.local.size.ll
  llvm/test/CodeGen/AMDGPU/mad24-get-global-id.ll
  llvm/test/CodeGen/AMDGPU/mad_int24.ll
  llvm/test/CodeGen/AMDGPU/mad_uint24.ll
  llvm/test/CodeGen/AMDGPU/mul.i16.ll
  llvm/test/CodeGen/AMDGPU/mul_int24.ll
  llvm/test/CodeGen/AMDGPU/mul_uint24-amdgcn.ll
  llvm/test/CodeGen/AMDGPU/mul_uint24-r600.ll
  llvm/test/CodeGen/AMDGPU/srem.ll
  llvm/test/CodeGen/AMDGPU/trunc-combine.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97063.325015.patch
Type: text/x-patch
Size: 49383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210219/39af15d0/attachment.bin>


More information about the llvm-commits mailing list