mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Stay rational; don't assert trying to take the square root of a negative value.
If it's negative, the loop is already proven to be infinite. Fixes PR13489! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161107 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -5370,6 +5370,12 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
|
||||
SqrtTerm *= B;
|
||||
SqrtTerm -= Four * (A * C);
|
||||
|
||||
if (SqrtTerm.isNegative()) {
|
||||
// The loop is provably infinite.
|
||||
const SCEV *CNC = SE.getCouldNotCompute();
|
||||
return std::make_pair(CNC, CNC);
|
||||
}
|
||||
|
||||
// Compute sqrt(B^2-4ac). This is guaranteed to be the nearest
|
||||
// integer value or else APInt::sqrt() will assert.
|
||||
APInt SqrtVal(SqrtTerm.sqrt());
|
||||
|
Reference in New Issue
Block a user