[SCEV] Be less eager about demoting zexts to sexts
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 3 Mar 2016 18:31:23 +0000 (18:31 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 3 Mar 2016 18:31:23 +0000 (18:31 +0000)
commit11ef606f1d33a8c368b1d071631eba28ae50a94c
tree79bdd16a756c3b1322cd4e143e6de3e4760b8bf1
parentf3867e64a82570990461e377c44887a310389ce8
[SCEV] Be less eager about demoting zexts to sexts

After r262438 we can have provably positive NSW SCEV expressions whose
zero extensions cannot be simplified (since r262438 makes SCEV better at
computing constant ranges).  This means demoting sexts of positive add
recurrences eagerly can result in an unsimplified zero extension where
we could have had a simplified sign extension.  This change fixes the
issue by teaching SCEV to demote sext of a positive SCEV expression to a
zext only if the sext could not be simplified.

llvm-svn: 262638
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/sext-to-zext.ll [new file with mode: 0644]