Don't crash in SE dealing with ashr x, -1
authorHal Finkel <hfinkel@anl.gov>
Tue, 9 Jul 2013 18:16:16 +0000 (18:16 +0000)
committerHal Finkel <hfinkel@anl.gov>
Tue, 9 Jul 2013 18:16:16 +0000 (18:16 +0000)
commitff666bd962a4446d80955fe75619201c29795501
tree3d97fd8d78031aa12d48ffc0e00578b97d242b99
parenta92b3c914ebb356aec22c978eae9fa9543fa62e6
Don't crash in SE dealing with ashr x, -1

ScalarEvolution::getSignedRange uses ComputeNumSignBits from ValueTracking on
ashr instructions. ComputeNumSignBits can return zero, but this case was not
handled correctly by the code in getSignedRange which was calling:
  APInt::getSignedMinValue(BitWidth).ashr(NS - 1)
with NS = 0, resulting in an assertion failure in APInt::ashr.

Now, we just return the conservative result (as with NS == 1).

Another bug found by llvm-stress.

llvm-svn: 185955
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/CodeGen/PowerPC/ashr-neg1.ll [new file with mode: 0644]