[PATCH] D13161: [PATCH, PR24373] Combine shifts for x86

Evgeny Stupachenko via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 05:01:34 PDT 2015


evstupac created this revision.
evstupac added reviewers: llvm-commits, nadav, majnemer.
evstupac added a subscriber: llvm-commits.
evstupac set the repository for this revision to rL LLVM.

The patch folds
  (ashr (shl, a, [56,48,32,24,16]), SarConst)
into
  (shl, (sext (a), [56,48,32,24,16] - SarConst))
or into
  (lshr, (sext (a), SarConst - [56,48,32,24,16]))
depending on sign of (SarConst - [56,48,32,24,16])

sexts in X86 are MOVs. The MOVs have the same code size as above SHIFTs (only SHIFT on 1 has lower code size).
However the MOVs have 2 advantages to SHIFTs on x86:
1. MOVs can write to a register that differs from source
2. MOVs accept memory operands


Repository:
  rL LLVM

http://reviews.llvm.org/D13161

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/2009-05-23-dagcombine-shifts.ll
  test/CodeGen/X86/sar_fold.ll
  test/CodeGen/X86/sar_fold64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13161.35714.patch
Type: text/x-patch
Size: 5569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150925/f8611488/attachment.bin>


More information about the llvm-commits mailing list