[InstCombine] Optimize lshr+shl+and conversion pattern
authorchenglin.bi <chenglin.bi@cixcomputing.com>
Tue, 14 Jun 2022 03:06:10 +0000 (11:06 +0800)
committerchenglin.bi <chenglin.bi@cixcomputing.com>
Tue, 14 Jun 2022 03:06:10 +0000 (11:06 +0800)
commit286198ff043afa7626705fb69c3e9b8873193573
tree87ff6e5dddf3d2551c58275609f2d4888bbfecba
parente99c07a30e2d8d5010bffdfdc14903c93a8e132d
[InstCombine] Optimize lshr+shl+and conversion pattern

if `C1` and `C3` are pow2 and `Log2(C3) >= C2`:
    ((C1 >> X) << C2) & C3 -> X == (Log2(C1)+C2-Log2(C3)) ? C3 : 0
https://alive2.llvm.org/ce/z/zvrkKF

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D127469
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and.ll