]> granicus.if.org Git - llvm/commit
[InstCombine] fold a shifted bool zext to a select (2nd try)
authorSanjay Patel <spatel@rotateright.com>
Tue, 15 Oct 2019 13:12:44 +0000 (13:12 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 15 Oct 2019 13:12:44 +0000 (13:12 +0000)
commit245690544de2a29297b08f91bdd588867a043ba8
treeed746e4c0f857645c6437ccfa0bd9e45a50fc9a6
parentb75805f86228651cca0431c5d9e9a6b248bf9519
[InstCombine] fold a shifted bool zext to a select (2nd try)

The 1st attempt at rL374828 inserted the code
at the wrong position (outside of the constant-shift-amount
block). Trying again with an additional test to verify
const-ness.

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@374886 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineShifts.cpp
test/Transforms/InstCombine/and.ll
test/Transforms/InstCombine/shift.ll