]> granicus.if.org Git - llvm/commit
[InstCombine] Bypass high bit extract before variable sign-extension (PR43523)
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 2 Oct 2019 23:02:12 +0000 (23:02 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 2 Oct 2019 23:02:12 +0000 (23:02 +0000)
commita213b6762a51e964cb97d4749291a859096805bd
treeffb1d783700fa1055ed9919d366c71572d114430
parent3607fde43ebda11daa1da0e913762552d28c3e5e
[InstCombine] Bypass high bit extract before variable sign-extension (PR43523)

https://rise4fun.com/Alive/8BY - valid for lshr+trunc+variable sext
https://rise4fun.com/Alive/7jk - the variable sext can be redundant

https://rise4fun.com/Alive/Qslu - 'exact'-ness of first shift can be preserver

https://rise4fun.com/Alive/IF63 - without trunc we could view this as
                                  more general "drop redundant mask before right-shift",
                                  but let's handle it here for now
https://rise4fun.com/Alive/iip - likewise, without trunc, variable sext can be redundant.

There's more patterns for sure - e.g. we can have 'lshr' as the final shift,
but that might be best handled by some more generic transform, e.g.
"drop redundant masking before right-shift" (PR42456)

I'm singling-out this sext patch because you can only extract
high bits with `*shr` (unlike abstract bit masking),
and i *know* this fold is wanted by existing code.

I don't believe there is much to review here,
so i'm gonna opt into post-review mode here.

https://bugs.llvm.org/show_bug.cgi?id=43523

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373542 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineInternal.h
lib/Transforms/InstCombine/InstCombineShifts.cpp
test/Transforms/InstCombine/variable-signext-of-variable-high-bit-extraction.ll