[PATCH] D47823: AMDGPU: Try a lot harder to emit scalar loads

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 06:16:18 PDT 2018


arsenm created this revision.
arsenm added reviewers: rampitec, kzhuravl, cfang.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng.

This has two main components. First, widen
widen short constant loads in DAG when they have
the correct alignment. This is already done a bit in
AMDGPUCodeGenPrepare, since that has access to
DivergenceAnalysis. This can't help kernarg loads
created in the DAG. Start to use DAG divergence analysis
to help this case.

      

The second part is to avoid kernel argument lowering
breaking the alignment of short vector elements because
calling convention lowering wants to split everything
into legal register types.

      

When loading a split type, load the nearest 4-byte aligned
segment and shift to get the desired bits. This extra
load of the earlier argument piece ends up merging,
and the bit extract hopefully folds out.

      

There are a number of improvements and regressions with
this, but I think as-is this is a better compromise between
several of the worst parts of SelectionDAG.

      

Particularly when i16 is legal, this produces worse code
for i8 and i16 element vector kernel arguments. This is
partially due to the very weak load merging the DAG does.
It only looks for fairly specific combines between pairs
of loads which no longer appear. In particular this
causes v4i16 loads to be split into 2 components when
previously the two halves were merged.

      

Worse, because of the newly introduced shifts, there
is a lot more unnecessary vector packing and unpacking code
emitted. At least some of this is due to reporting
false for isTypeDesirableForOp for i16 as a workaround for
the lack of divergence information in the DAG. The cases
where this happens it doesn't actually matter, but the
relevant code in SimplifyDemandedBits doens't have the context
to know to ignore this.

      

The use of the  scalar cache is probably more important
than the mess of mostly scalar instructions doing this packing
and unpacking. Future work can fix this, possibly by making better
use of the new DAG divergence information for controlling promotion
decisions, or adding another version of shift + trunc + shift
combines that doesn't only know about the used types.


https://reviews.llvm.org/D47823

Files:
  lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  lib/Target/AMDGPU/SIISelLowering.cpp
  lib/Target/AMDGPU/SIISelLowering.h
  test/CodeGen/AMDGPU/and.ll
  test/CodeGen/AMDGPU/ashr.v2i16.ll
  test/CodeGen/AMDGPU/basic-branch.ll
  test/CodeGen/AMDGPU/cf-loop-on-constant.ll
  test/CodeGen/AMDGPU/extract_vector_elt-f16.ll
  test/CodeGen/AMDGPU/extract_vector_elt-i16.ll
  test/CodeGen/AMDGPU/extract_vector_elt-i8.ll
  test/CodeGen/AMDGPU/fabs.f16.ll
  test/CodeGen/AMDGPU/fneg-fabs.f16.ll
  test/CodeGen/AMDGPU/fneg.f16.ll
  test/CodeGen/AMDGPU/half.ll
  test/CodeGen/AMDGPU/imm16.ll
  test/CodeGen/AMDGPU/insert_vector_elt.ll
  test/CodeGen/AMDGPU/kernel-args.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.buffer.store.format.d16.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.class.f16.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.image.d16.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.tbuffer.store.d16.ll
  test/CodeGen/AMDGPU/lshr.v2i16.ll
  test/CodeGen/AMDGPU/min.ll
  test/CodeGen/AMDGPU/reduce-store-width-alignment.ll
  test/CodeGen/AMDGPU/select-i1.ll
  test/CodeGen/AMDGPU/sext-in-reg.ll
  test/CodeGen/AMDGPU/shl.v2i16.ll
  test/CodeGen/AMDGPU/sminmax.v2i16.ll
  test/CodeGen/AMDGPU/widen-smrd-loads.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47823.150123.patch
Type: text/x-patch
Size: 85898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180606/55a8013a/attachment.bin>


More information about the llvm-commits mailing list