]> granicus.if.org Git - llvm/commit
[AArch64][GlobalISel] Make s8 and s16 G_CONSTANTs legal.
authorAmara Emerson <aemerson@apple.com>
Fri, 21 Jun 2019 16:43:50 +0000 (16:43 +0000)
committerAmara Emerson <aemerson@apple.com>
Fri, 21 Jun 2019 16:43:50 +0000 (16:43 +0000)
commit2d73fb9e310a46d9dfb36a967d4377367d647c7c
tree019c4646c85fde1bb0760b9e9f746afd80b483c8
parentb9c9b022fcabea7f3c2a86857a5c00a834bae29b
[AArch64][GlobalISel] Make s8 and s16 G_CONSTANTs legal.

We sometimes get poor code size because constants of types < 32b are legalized
as 32 bit G_CONSTANTs with a truncate to fit. This works but means that the
localizer can no longer sink them (although it's possible to extend it to do so).

On AArch64 however s8 and s16 constants can be selected in the same way as s32
constants, with a mov pseudo into a W register. If we make s8 and s16 constants
legal then we can avoid unnecessary truncates, they can be CSE'd, and the
localizer can sink them as normal.

There is a caveat: if the user of a smaller constant has to widen the sources,
we end up with an anyext of the smaller typed G_CONSTANT. This can cause
regressions because of the additional extend and missed pattern matching. To
remedy this, there's a new artifact combiner to generate the wider G_CONSTANT
if it's legal for the target.

Differential Revision: https://reviews.llvm.org/D63587

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364075 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
lib/Target/AArch64/AArch64InstructionSelector.cpp
lib/Target/AArch64/AArch64LegalizerInfo.cpp
test/CodeGen/AArch64/GlobalISel/legalize-add.mir
test/CodeGen/AArch64/GlobalISel/legalize-atomicrmw.mir
test/CodeGen/AArch64/GlobalISel/legalize-cmpxchg.mir
test/CodeGen/AArch64/GlobalISel/legalize-constant.mir
test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir
test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir
test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir
test/CodeGen/AArch64/GlobalISel/legalizer-combiner-zext-trunc-crash.mir
test/CodeGen/AArch64/GlobalISel/legalizer-combiner.mir
test/CodeGen/AArch64/GlobalISel/select-constant.mir
test/CodeGen/AMDGPU/GlobalISel/legalize-anyext.mir
test/CodeGen/X86/GlobalISel/legalize-constant.mir