]> granicus.if.org Git - llvm/commit
[X86] Replace AND+IMM64 with SRL/SHL
authorNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 12 Jan 2017 19:54:27 +0000 (19:54 +0000)
committerNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 12 Jan 2017 19:54:27 +0000 (19:54 +0000)
commit7b4bd48edb52987bc4c36e57422572fe99606449
tree2f0d217e841b12308d45df792ea0d179f65f60fc
parent7257b8b517f69e8af679a1631c5fb6d6e9bd56cf
[X86] Replace AND+IMM64 with SRL/SHL

Emit SHRQ/SHLQ instead of ANDQ with a 64 bit constant mask if the result
is unused and the mask has only higher/lower bits set. For example, with
this patch LLVM emits

  shrq $41, %rdi
  je

instead of

  movabsq $0xFFFFFE0000000000, %rcx
  testq   %rcx, %rdi
  je

This reduces number of instructions, code size and register pressure.
The transformation is applied only for cases where the mask cannot be
encoded as an immediate value within TESTQ instruction.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291806 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/bypass-slow-division-64.ll
test/CodeGen/X86/bypass-slow-division-tune.ll
test/CodeGen/X86/cmp.ll