X86: More efficient legalization of wide integer compares
authorHans Wennborg <hans@hanshq.net>
Thu, 19 Nov 2015 16:35:08 +0000 (16:35 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 19 Nov 2015 16:35:08 +0000 (16:35 +0000)
commit086b179985b193f50250faf475a47d7f3e6e4783
tree9ff9544c8300ce60b2595010ab6b0c47c5acf562
parentd19cbfed93dfe8ac34c6ee39104611254b31bddb
X86: More efficient legalization of wide integer compares

In particular, this makes the code for 64-bit compares on 32-bit targets
much more efficient.

Example:

  define i32 @test_slt(i64 %a, i64 %b) {
  entry:
    %cmp = icmp slt i64 %a, %b
    br i1 %cmp, label %bb1, label %bb2
  bb1:
    ret i32 1
  bb2:
    ret i32 2
  }

Before this patch:

  test_slt:
          movl    4(%esp), %eax
          movl    8(%esp), %ecx
          cmpl    12(%esp), %eax
          setae   %al
          cmpl    16(%esp), %ecx
          setge   %cl
          je      .LBB2_2
          movb    %cl, %al
  .LBB2_2:
          testb   %al, %al
          jne     .LBB2_4
          movl    $1, %eax
          retl
  .LBB2_4:
          movl    $2, %eax
          retl

After this patch:

  test_slt:
          movl    4(%esp), %eax
          movl    8(%esp), %ecx
          cmpl    12(%esp), %eax
          sbbl    16(%esp), %ecx
          jge     .LBB1_2
          movl    $1, %eax
          retl
  .LBB1_2:
          movl    $2, %eax
          retl

Differential Revision: http://reviews.llvm.org/D14496

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253572 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
include/llvm/CodeGen/ISDOpcodes.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h
lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
test/CodeGen/X86/2012-08-17-legalizer-crash.ll
test/CodeGen/X86/atomic-minmax-i6432.ll
test/CodeGen/X86/atomic128.ll
test/CodeGen/X86/avx512-cmp.ll
test/CodeGen/X86/wide-integer-cmp.ll [new file with mode: 0644]
test/CodeGen/X86/win32-pic-jumptable.ll