From fe3516f9a5f238ecf6872b5315706c7c7942a496 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 30 May 2012 03:35:20 +0000 Subject: SCEV: Handle a corner case reducing AddRecExpr * AddRecExpr If integer overflow causes one of the terms to reach zero, that can force the entire expression to zero. Fixes PR12929: cast() argument of incompatible type git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157673 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolution.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Analysis/ScalarEvolution.cpp') diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 59f441e700..8781441fd4 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2088,9 +2088,12 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl &Ops, const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRec->getLoop(), SCEV::FlagAnyWrap); if (Ops.size() == 2) return NewAddRec; - Ops[Idx] = AddRec = cast(NewAddRec); + Ops[Idx] = NewAddRec; Ops.erase(Ops.begin() + OtherIdx); --OtherIdx; OpsModified = true; + AddRec = dyn_cast(NewAddRec); + if (!AddRec) + break; } } if (OpsModified) -- cgit v1.2.3-18-g5258