[PATCH] D71952: [X86][InstCombine] Add constant folding and simplification support for pdep and pext

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 27 16:54:03 PST 2019


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, xbolva00, lebedev.ri.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

The instructions use a mask to either pack disjoint bits together(pext) or spread bits to disjoint locations(pdep). If the mask is all 0s then no bits are extracted or deposited. If the mask is all ones, then the source value is written to the result since no compression or expansion happens. Otherwise if both the source and mask are constant we can walk the bits in the source/mask and calculate the result.

There other crazier things we could do like computeKnownBits or turning pext into shift/and if only a single contiguous range of bits is extracted.

Fixes PR44389


https://reviews.llvm.org/D71952

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/X86/x86-bmi-tbm.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71952.235453.patch
Type: text/x-patch
Size: 7041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191228/fba09a5b/attachment.bin>


More information about the llvm-commits mailing list