[PATCH] D78092: [GlobalISel][AMDGPU] add legalization for G_FREEZE

Dominik Montada via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 07:48:45 PDT 2020


gargaroff added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:843-846
+    SmallVector<Register, 2> SrcRegs, LeftoverRegs, DstRegs, LeftoverDstRegs;
+    if (!extractParts(SrcReg, SrcTy, NarrowTy, LeftoverTy, SrcRegs,
+                      LeftoverRegs))
+      return UnableToLegalize;
----------------
arsenm wrote:
> I've been working on eliminating these somewhat awkward functions that end up producing G_INSERT/G_EXTRACT in odd breakdowns instead of creating intermediate merges to the requested type. fewerElementsVectorBasic should be pretty close to what this should do? (Although maybe pad with undef is the wrong choice here)
It was pretty close to what was needed indeed. I just had to change some parameters to some function calls, but otherwise it's mostly a copy of `fewerElementsVectorBasic`.

I didn't bother with refactoring both to reuse most of the unchanged code yet to get a first feedback on the narrowing action. Also I need to check how well the code can be shared in the first place. Btw, if you have a suggestion on how such a shared function could be named, I'm open for suggestions because I'm struggling to come up with a meaningful name.

Also, I decided to use undef padding here, since @aqjune said that undef bits are fine, because they get frozen anyway.


================
Comment at: llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp:2970
+// Test more elements of G_FREEZE
+TEST_F(AArch64GISelMITest, MoreElementsFreeze) {
+  setUp();
----------------
arsenm wrote:
> If you want some tests that are less inconvenient than unit tests, for AMDGPU this should have the same legalization action as G_IMPLICIT_DEF (and probably true for all targets)
I went ahead and added the same legalization actions for `G_FREEZE` as `G_IMPLICIT_DEF` and have basically copied all tests from `legalizeImplicitDef` to `legalizeFreeze` and modified them to use `G_FREEZE`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78092/new/

https://reviews.llvm.org/D78092





More information about the llvm-commits mailing list