OSDN Git Service

[InstSimplify] add folds for constant mask of value shifted by constant
authorSanjay Patel <spatel@rotateright.com>
Tue, 16 May 2017 21:51:04 +0000 (21:51 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 16 May 2017 21:51:04 +0000 (21:51 +0000)
commit25529caa1bfe205fbd7175e3136b484910195985
tree6c0f97b37bd7d96128684e61a7598996112ea415
parent10dbbfe1c9d68bed0deb05766ce1b4c84f814166
[InstSimplify] add folds for constant mask of value shifted by constant

We would eventually catch these via demanded bits and computing known bits in InstCombine,
but I think it's better to handle the simple cases as soon as possible as a matter of efficiency.

This fold allows further simplifications based on distributed ops transforms. eg:
  %a = lshr i8 %x, 7
  %b = or i8 %a, 2
  %c = and i8 %b, 1

InstSimplify can directly fold this now:
  %a = lshr i8 %x, 7

Differential Revision: https://reviews.llvm.org/D33221

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303213 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/AndOrXor.ll