[PATCH] D13956: [x86] try harder to match bitwise 'or' into an LEA

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 13:43:05 PDT 2015


spatel created this revision.
spatel added reviewers: chandlerc, qcolombet, silvas.
spatel added a subscriber: llvm-commits.

The motivation for this patch starts with the epic fail example in PR18007:
https://llvm.org/bugs/show_bug.cgi?id=18007

...unfortunately, this patch makes no difference for that case, but it solves some simpler cases. We'll get there some day. :)

The current 'or' matching code was using computeKnownBits() via isBaseWithConstantOffset() -> MaskedValueIsZero(), but that's an unnecessarily limited use. We can do more by copying the logic in ValueTracking's haveNoCommonBitsSet(), so we can treat the 'or' as if it was an 'add'.

An example of the better LEA matching:
   leal (%rdi,%rdi), %eax
   andl $1, %esi
   orl %esi, %eax

Becomes:
   andl $1, %esi
   leal (%rsi,%rdi,2), %eax



http://reviews.llvm.org/D13956

Files:
  lib/Target/X86/X86ISelDAGToDAG.cpp
  test/CodeGen/X86/or-lea.ll
  test/CodeGen/X86/x86-64-double-precision-shift-left.ll
  test/CodeGen/X86/x86-64-double-precision-shift-right.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13956.38041.patch
Type: text/x-patch
Size: 5499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151021/ef606ffb/attachment.bin>


More information about the llvm-commits mailing list