From e96fec2e436003714a6bf3739d594d77701da1e5 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 15 Jan 2014 03:35:46 +0000 Subject: LoopVectorize: Only strip casts from integer types when replacing symbolic strides Fixes PR18480. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199291 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Vectorize/LoopVectorize.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp') diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index bdfa0f0647..c05288bd07 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1072,9 +1072,10 @@ struct LoopVectorize : public LoopPass { // LoopVectorizationCostModel. //===----------------------------------------------------------------------===// -static Value *stripCast(Value *V) { +static Value *stripIntegerCast(Value *V) { if (CastInst *CI = dyn_cast(V)) - return CI->getOperand(0); + if (CI->getOperand(0)->getType()->isIntegerTy()) + return CI->getOperand(0); return V; } @@ -1095,7 +1096,7 @@ static const SCEV *replaceSymbolicStrideSCEV(ScalarEvolution *SE, Value *StrideVal = SI->second; // Strip casts. - StrideVal = stripCast(StrideVal); + StrideVal = stripIntegerCast(StrideVal); // Replace symbolic stride by one. Value *One = ConstantInt::get(StrideVal->getType(), 1); @@ -1551,7 +1552,7 @@ InnerLoopVectorizer::addStrideCheck(Instruction *Loc) { for (SmallPtrSet::iterator SI = Legal->strides_begin(), SE = Legal->strides_end(); SI != SE; ++SI) { - Value *Ptr = stripCast(*SI); + Value *Ptr = stripIntegerCast(*SI); Value *C = ChkBuilder.CreateICmpNE(Ptr, ConstantInt::get(Ptr->getType(), 1), "stride.chk"); // Store the first instruction we create. -- cgit v1.2.3