[PATCH] D34141: [X86] Recognize constant arrays with special values and replace loads from it with subtract and shift instructions, which then may be replaced by BZHI machine instruction.

Ayman Musa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 05:07:14 PDT 2017


aymanmus created this revision.

Recognize constant arrays with the following values:

  0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, .... , 2^(size - 1) -1

where //size// is the size of the array.
the result of a load with index //idx// from this array is equivalent to the result of the following:

  (0xFFFFFFFF >> (sub 32, idx))             (assuming the array of type 32-bit integer).

This transformations also prepares the way of a pattern match for bzhi instruction when:

1. Target has BMI2 extension.
2. The result of the load is and operand of an //and// instruction.

See last 2 test cases in the .ll file for better understanding.


https://reviews.llvm.org/D34141

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/CodeGenPrepare.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  test/CodeGen/X86/replace-load-with-sub-shr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34141.102314.patch
Type: text/x-patch
Size: 8724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/c6d061c3/attachment.bin>


More information about the llvm-commits mailing list