[InstCombine] improve fold for icmp-ugt-ashr
authorChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Thu, 9 Jun 2022 08:15:42 +0000 (16:15 +0800)
committerChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Thu, 9 Jun 2022 08:22:12 +0000 (16:22 +0800)
commit38992d2c5e1d671cf5d4f03c7331ce98b2cdda94
tree835cea697c1be8b930eadba87f42cdf8d0da0495
parent91e31fd2056afeb3dc490cb2665a09cf7ef06cda
[InstCombine] improve fold for icmp-ugt-ashr

Existing condition for
fold icmp ugt (ashr X, ShAmtC), C --> icmp ugt X, ((C + 1) << ShAmtC) - 1
missed some boundary. It cause this fold don't work for some cases, and the
reason is due to signed number overflow.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D127188
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-shr.ll