mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
Don't crash analyzing certain quadratics (addrec of {X,+,Y,+,1}).
We're still waiting on code that actually analyzes them properly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58592 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ae61ca0206
commit
8f4d5eb9e5
@ -2604,6 +2604,11 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
|
|||||||
// The divisions must be performed as signed divisions.
|
// The divisions must be performed as signed divisions.
|
||||||
APInt NegB(-B);
|
APInt NegB(-B);
|
||||||
APInt TwoA( A << 1 );
|
APInt TwoA( A << 1 );
|
||||||
|
if (TwoA.isMinValue()) {
|
||||||
|
SCEV *CNC = new SCEVCouldNotCompute();
|
||||||
|
return std::make_pair(CNC, CNC);
|
||||||
|
}
|
||||||
|
|
||||||
ConstantInt *Solution1 = ConstantInt::get((NegB + SqrtVal).sdiv(TwoA));
|
ConstantInt *Solution1 = ConstantInt::get((NegB + SqrtVal).sdiv(TwoA));
|
||||||
ConstantInt *Solution2 = ConstantInt::get((NegB - SqrtVal).sdiv(TwoA));
|
ConstantInt *Solution2 = ConstantInt::get((NegB - SqrtVal).sdiv(TwoA));
|
||||||
|
|
||||||
|
21
test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll
Normal file
21
test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; RUN: llvm-as < %s | opt -analyze -scalar-evolution
|
||||||
|
; PR1827
|
||||||
|
|
||||||
|
declare void @use(i32)
|
||||||
|
|
||||||
|
define void @foo() {
|
||||||
|
entry:
|
||||||
|
br label %loop_1
|
||||||
|
|
||||||
|
loop_1: ; preds = %loop_1, %entry
|
||||||
|
%a = phi i32 [ 2, %entry ], [ %b, %loop_1 ] ; <i32> [#uses=2]
|
||||||
|
%c = phi i32 [ 5, %entry ], [ %d, %loop_1 ] ; <i32> [#uses=1]
|
||||||
|
%b = add i32 %a, 1 ; <i32> [#uses=1]
|
||||||
|
%d = add i32 %c, %a ; <i32> [#uses=3]
|
||||||
|
%A = icmp ult i32 %d, 50 ; <i1> [#uses=1]
|
||||||
|
br i1 %A, label %loop_1, label %endloop
|
||||||
|
|
||||||
|
endloop: ; preds = %loop_1
|
||||||
|
call void @use(i32 %d)
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user