]> granicus.if.org Git - llvm/commit
[InstCombine] fold a shifted bool zext to a select
authorSanjay Patel <spatel@rotateright.com>
Mon, 14 Oct 2019 21:56:40 +0000 (21:56 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 14 Oct 2019 21:56:40 +0000 (21:56 +0000)
commit17f93c96ec6c1ed1f2bd39dcfd7e517eaa79df70
tree43ef1692f19f5a39e1ca669b9906e4dba420f14a
parente122082aec0233446f11b4248ac3ae802b2cce8a
[InstCombine] fold a shifted bool zext to a select

For a constant shift amount, add the following fold.
shl (zext (i1 X)), ShAmt --> select (X, 1 << ShAmt, 0)

https://rise4fun.com/Alive/IZ9

Fixes PR42257.

Based on original patch by @zvi (Zvi Rackover)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374828 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineShifts.cpp
test/Transforms/InstCombine/and.ll
test/Transforms/InstCombine/shift.ll