OSDN Git Service

[GlobalISel][X86] Support G_LSHR/G_ASHR/G_SHL
authorAlexander Ivchenko <alexander.ivchenko@intel.com>
Wed, 14 Mar 2018 11:23:57 +0000 (11:23 +0000)
committerAlexander Ivchenko <alexander.ivchenko@intel.com>
Wed, 14 Mar 2018 11:23:57 +0000 (11:23 +0000)
commit5b113a2c3b054e1d894ab9e44a6a08e1d0cd7ff3
treee725e782e71be9c6522180bfadbe6055f3cd3a98
parent9357220c93d21227d72b0e4d40d1f5f3e3dbe8a0
[GlobalISel][X86] Support G_LSHR/G_ASHR/G_SHL

Support G_LSHR/G_ASHR/G_SHL. We have 3 variance for
shift instructions : shift gpr, shift imm, shift 1.
Currently GlobalIsel TableGen generate patterns for
shift imm and shift 1, but with shiftCount i8.
In G_LSHR/G_ASHR/G_SHL like LLVM-IR both arguments
has the same type, so for now only shift i8 can use
auto generated TableGen patterns.

The support of G_SHL/G_ASHR enables tryCombineSExt
from LegalizationArtifactCombiner.h to hit, which
results in different legalization for the following tests:
    LLVM :: CodeGen/X86/GlobalISel/ext-x86-64.ll
    LLVM :: CodeGen/X86/GlobalISel/gep.ll
    LLVM :: CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir

-; X64-NEXT:    movsbl %dil, %eax
+; X64-NEXT:    movl $24, %ecx
+; X64-NEXT:    # kill: def $cl killed $ecx
+; X64-NEXT:    shll %cl, %edi
+; X64-NEXT:    movl $24, %ecx
+; X64-NEXT:    # kill: def $cl killed $ecx
+; X64-NEXT:    sarl %cl, %edi
+; X64-NEXT:    movl %edi, %eax

..which is not optimal and should be addressed later.

Rework of the patch by igorb

Reviewed By: igorb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327499 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
lib/Target/X86/X86InstructionSelector.cpp
lib/Target/X86/X86LegalizerInfo.cpp
lib/Target/X86/X86RegisterBankInfo.cpp
test/CodeGen/X86/GlobalISel/ashr-scalar.ll [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/ext-x86-64.ll
test/CodeGen/X86/GlobalISel/ext.ll
test/CodeGen/X86/GlobalISel/gep.ll
test/CodeGen/X86/GlobalISel/legalize-ashr-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir
test/CodeGen/X86/GlobalISel/legalize-lshr-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/legalize-shl-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/lshr-scalar.ll [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/select-ashr-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/select-lshr-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/select-shl-scalar.mir [new file with mode: 0644]
test/CodeGen/X86/GlobalISel/shl-scalar.ll [new file with mode: 0644]