[PATCH] D86057: GlobalISel: Reduce G_SHL width if source is extension

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 05:28:40 PDT 2020


arsenm created this revision.
arsenm added reviewers: aemerson, paquette, aditya_nandakumar, rampitec, Petar.Avramovic, foad, mbrkusanin.
Herald added subscribers: kerbowa, hiraditya, tpr, rovka, nhaehnle, jvesely.
Herald added a project: LLVM.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

shl ([sza]ext x, y) => zext (shl x, y).

      

Turns expensive 64 bit shifts into 32 bit if it does not overflow the
source type:

      

This is a port of an AMDGPU DAG combine added in
5fa289f0d8ff85b9e14d2f814a90761378ab54ae. InstCombine does this
already, but we need to do it again here to apply it to shifts
introduced for lowered getelementptrs. This will help matching
addressing modes that use 32-bit offsets in a future patch.

      

TableGen annoyingly assumes only a single match data operand, so
introduce a reusable struct. However, this still requires defining a
separate GIMatchData for every combine which is still annoying.

      

Adds a morally equivalent function to the existing
getShiftAmountTy. Without this, we would have to do try to repeatedly
query the legalizer info and guess at what type to use for the shift.


https://reviews.llvm.org/D86057

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCombine.td
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h
  llvm/test/CodeGen/AMDGPU/GlobalISel/combine-shl-from-extend-narrow.postlegal.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/combine-shl-from-extend-narrow.prelegal.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/shl-ext-reduce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86057.285975.patch
Type: text/x-patch
Size: 51461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200817/649e8551/attachment.bin>


More information about the llvm-commits mailing list