[PATCH] D89100: [GlobalISel] Look through truncs and extends in narrowScalarShift

Konstantin Schwarz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 01:02:51 PDT 2020


kschwarz created this revision.
kschwarz added reviewers: arsenm, aditya_nandakumar.
Herald added subscribers: kerbowa, hiraditya, rovka, nhaehnle, jvesely.
Herald added a project: LLVM.
kschwarz requested review of this revision.
Herald added a subscriber: wdng.

If a G_SHL is fed by a G_CONSTANT, the lower and upper bits of the source can be
shifted individually by the constant shift amount.

However in case the shift amount came from a G_TRUNC(G_CONSTANT), the generic shift legalization
code was used, producing potentially illegal intermediate shifts.

Later code in GIselKnownBits would assert that the constant shift amount is bigger than the bit-width
of the source type.

This change teaches narrowScalarShift to look through G_TRUNCs and G_*EXTs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89100

Files:
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/saddsat.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/ssubsat.ll
  llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89100.297139.patch
Type: text/x-patch
Size: 192861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201009/078b1e43/attachment-0001.bin>


More information about the llvm-commits mailing list