[GlobalISel] support narrow G_IMPLICIT_DEF for DstSize % NarrowSize != 0
authorDominik Montada <dominik.montada@hightec-rt.com>
Mon, 23 Mar 2020 11:30:55 +0000 (12:30 +0100)
committerDominik Montada <dominik.montada@hightec-rt.com>
Wed, 8 Apr 2020 09:00:07 +0000 (11:00 +0200)
commit35950fea8d4f175d04aa27e5e0350e28bef36429
treebcf93058a77ef282fc1ef6ab149f10532ac48288
parent2a6eedbb51fd612d3386b0379938036b17511ae0
[GlobalISel] support narrow G_IMPLICIT_DEF for DstSize % NarrowSize != 0

Summary:
When narrowing G_IMPLICIT_DEF where the original size is not a multiple
of the narrow size, emit a smaller G_IMPLICIT_DEF and use G_ANYEXT.

To prevent a potential endless loop in the legalizer, the condition
to combine G_ANYEXT(G_IMPLICIT_DEF) is changed from isInstUnsupported
to !isInstLegal, since in this case the combine is only valid if
consequent legalization of the newly combined G_IMPLICIT_DEF does not
introduce G_ANYEXT due to narrowing.

Although this legalization for G_IMPLICIT_DEF would also be valid for
the general case, it actually caused a lot of code regressions when
tried due to superfluous COPYs and combines not getting hit anymore.

Reviewers: dsanders, aemerson, volkan, arsenm, aditya_nandakumar

Reviewed By: arsenm

Subscribers: jvesely, nhaehnle, kerbowa, wdng, rovka, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76598
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def-s1025.mir [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def.mir
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp