OSDN Git Service

[AArch64][GlobalISel] Optimize compare and branch cases with G_INTTOPTR and unknown...
authorAmara Emerson <aemerson@apple.com>
Wed, 10 Jul 2019 19:21:43 +0000 (19:21 +0000)
committerAmara Emerson <aemerson@apple.com>
Wed, 10 Jul 2019 19:21:43 +0000 (19:21 +0000)
commit069ef12420d75e6702225f8cc2e210de76f23ba5
treef6609ef81e3d2c5f3447a17f0e011d48a57dc707
parentb18e44c72ebe1ce890065765aa82464e26059a65
[AArch64][GlobalISel] Optimize compare and branch cases with G_INTTOPTR and unknown values.

Since we have distinct types for pointers and scalars, G_INTTOPTRs can sometimes
obstruct attempts to find constant source values. These usually come about when
try to do some kind of null pointer check. Teaching getConstantVRegValWithLookThrough
about this operation allows the CBZ/CBNZ optimization to catch more cases.

This change also improves the case where we can't find a constant source at all.
Previously we would emit a cmp, cset and tbnz for that. Now we try to just emit
a cmp and conditional branch, saving an instruction.

The cumulative code size improvement of this change plus D64354 is 5.5% geomean
on arm64 CTMark -O0.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365690 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/GlobalISel/Utils.cpp
lib/Target/AArch64/AArch64InstructionSelector.cpp
test/CodeGen/AArch64/GlobalISel/select-cbz.mir
test/CodeGen/AArch64/GlobalISel/select-jump-table-brjt.mir
test/CodeGen/AArch64/GlobalISel/swifterror.ll