]> granicus.if.org Git - llvm/commit
[InstCombine] Fold 'icmp eq/ne (?trunc (lshr/ashr %x, bitwidth(x)-1)), 0' -> 'icmp...
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 4 Oct 2019 22:16:22 +0000 (22:16 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 4 Oct 2019 22:16:22 +0000 (22:16 +0000)
commit98b5e22e78973acfd4f5c6c0fbec323d7851cb69
tree78c6a702ca4154970e75d1616a57f4173eed31f1
parent6d4c970c3440a7d3418b3222b663438bc343c0db
[InstCombine] Fold 'icmp eq/ne (?trunc (lshr/ashr %x, bitwidth(x)-1)), 0' -> 'icmp sge/slt %x, 0'

We do indeed already get it right in some cases, but only transitively,
with one-use restrictions. Since we only need to produce a single
comparison, it makes sense to match the pattern directly:
  https://rise4fun.com/Alive/kPg

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373802 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/shift.ll
test/Transforms/InstCombine/sign-bit-test-via-right-shifting-all-other-bits.ll