[PATCH] D28198: [X86] Replace AND+IMM64 with SRL/SHL

Nikolai Bozhenov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 31 06:55:43 PST 2016


n.bozhenov created this revision.
n.bozhenov added reviewers: spatel, craig.topper, bkramer, jlebar.
n.bozhenov added subscribers: llvm-commits, zansari, DavidKreitzer, aaboud, volkalexey.

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.


https://reviews.llvm.org/D28198

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28198.82765.patch
Type: text/x-patch
Size: 7709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161231/ac92b614/attachment.bin>


More information about the llvm-commits mailing list