[PATCH] D44395: [GlobalISel][X86] Support G_LSHR/G_ASHR/G_SHL

Alexander Ivchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 12 10:11:48 PDT 2018


aivchenk created this revision.
aivchenk added reviewers: igorb, zvi, qcolombet.
Herald added subscribers: kristof.beyls, rovka.

  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 Igor Breger:
https://reviews.llvm.org/D38219

                                                                     


https://reviews.llvm.org/D44395

Files:
  lib/Target/X86/X86InstructionSelector.cpp
  lib/Target/X86/X86LegalizerInfo.cpp
  lib/Target/X86/X86RegisterBankInfo.cpp
  test/CodeGen/X86/GlobalISel/ashr-scalar.ll
  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
  test/CodeGen/X86/GlobalISel/legalize-ext-x86-64.mir
  test/CodeGen/X86/GlobalISel/legalize-lshr-scalar.mir
  test/CodeGen/X86/GlobalISel/legalize-shl-scalar.mir
  test/CodeGen/X86/GlobalISel/lshr-scalar.ll
  test/CodeGen/X86/GlobalISel/select-ashr-scalar.mir
  test/CodeGen/X86/GlobalISel/select-lshr-scalar.mir
  test/CodeGen/X86/GlobalISel/select-shl-scalar.mir
  test/CodeGen/X86/GlobalISel/shl-scalar.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44395.138045.patch
Type: text/x-patch
Size: 74649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180312/181b91d5/attachment-0001.bin>


More information about the llvm-commits mailing list