[PATCH] D65088: [AMDGPU][RFC] New llvm.amdgcn.ballot intrinsic

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 06:38:53 PDT 2019


foad created this revision.
foad added reviewers: arsenm, nhaehnle, tpr, dstuttard.
Herald added subscribers: jfb, hiraditya, t-tye, yaxunl, wdng, jvesely, kzhuravl.
Herald added a project: LLVM.

Add a new llvm.amdgcn.ballot intrinsic modeled on the ballot function
in GLSL and other shader languages. It returns a bitfield containing the
result of its boolean argument in all active lanes, and zero in all
inactive lanes.

This is intended to replace the existing llvm.amdgcn.icmp and
llvm.amdgcn.fcmp intrinsics after a suitable transition period.

Use the new intrinsic in the atomic optimizer pass.

I'm not going to commit this as-is because tests are failing due to
poor code generation, e.g. test2 in ballot.ll generates:

v_cmp_eq_u32_e32 vcc, v0, v1
	v_cndmask_b32_e64 v0, 0, 1, vcc
	v_cmp_ne_u32_e64 s[4:5], 0, v0
	v_mov_b32_e32 v0, s4
	v_mov_b32_e32 v1, s5

instead of:

v_cmp_eq_u32_e32 s[4:5], v0, v1
	v_mov_b32_e32 v0, s4
	v_mov_b32_e32 v1, s5

I'd appreciate feedback on (a) the idea, (b) the implementation and
(c) how best to improve the code generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65088

Files:
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  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/ballot.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65088.211078.patch
Type: text/x-patch
Size: 35808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190722/8a62f445/attachment.bin>


More information about the llvm-commits mailing list