From 58deef5559db65f742fc67adcdaba04ce83f0764 Mon Sep 17 00:00:00 2001 From: David Greene Date: Tue, 5 May 2009 20:22:36 +0000 Subject: Handle overflow of 64-bit loop conditions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71008 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp') diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 4365adc629..23f75630b7 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2027,9 +2027,10 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, Scale = SSInt / CmpSSInt; int64_t NewCmpVal = CmpVal * Scale; - APInt Mul = APInt(BitWidth, NewCmpVal); + APInt Mul = APInt(BitWidth*2, CmpVal); + Mul = Mul * APInt(BitWidth*2, Scale); // Check for overflow. - if (Mul.getSExtValue() != NewCmpVal) + if (!Mul.isSignedIntN(BitWidth)) continue; // Watch out for overflow. -- cgit v1.2.3