[PATCH] D49229: [InstCombine] Fold redundant masking operations of shifted value

Diogo N. Sampaio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 12 05:44:43 PDT 2018


dnsampaio created this revision.
dnsampaio added reviewers: spatel, samparker, efriedma.
Herald added a subscriber: llvm-commits.

Allow to reduce redundant shift masks, at the IR level.
For example:
x1 = x & 0xAB00
x2 = (x >> 8) & 0xAB

The x2 operation can be seen as
x2 = (x >> 8) & (0xAB00 >> 8)

>
-

x2 = (x & 0xAB00) >> 8

And finally reduced to
x2 = x1 >> 8

It only allows folding when the masks and shift values are constants.


Repository:
  rL LLVM

https://reviews.llvm.org/D49229

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h
  test/Transforms/InstCombine/D48278.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49229.155155.patch
Type: text/x-patch
Size: 9025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180712/7558bc6a/attachment.bin>


More information about the llvm-commits mailing list