[llvm-branch-commits] [llvm-branch] r195991 - Merging r195787:
Bill Wendling
isanbard at gmail.com
Sat Nov 30 19:03:42 PST 2013
Author: void
Date: Sat Nov 30 21:03:42 2013
New Revision: 195991
URL: http://llvm.org/viewvc/llvm-project?rev=195991&view=rev
Log:
Merging r195787:
------------------------------------------------------------------------
r195787 | arnolds | 2013-11-26 14:11:23 -0800 (Tue, 26 Nov 2013) | 8 lines
LoopVectorizer: Truncate i64 trip counts of i32 phis if necessary
In signed arithmetic we could end up with an i64 trip count for an i32 phi.
Because it is signed arithmetic we know that this is only defined if the i32
does not wrap. It is therefore safe to truncate the i64 trip count to a i32
value.
Fixes PR18049.
------------------------------------------------------------------------
Added:
llvm/branches/release_34/test/Transforms/LoopVectorize/X86/tripcount.ll
- copied unchanged from r195787, llvm/trunk/test/Transforms/LoopVectorize/X86/tripcount.ll
Modified:
llvm/branches/release_34/ (props changed)
llvm/branches/release_34/lib/Transforms/Vectorize/LoopVectorize.cpp
Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 30 21:03:42 2013
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195408,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195493,195514,195528,195547,195567,195573-195576,195591,195599,195632,195635-195636,195670,195679,195682,195684,195713,195716,195769,195773,195779,195782,195791,195798,195827,195834,195887
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195136,195138,195148,195152,195156-195157,195161-195162,195193,195272,195317-195318,195327,195330,195333,195339,195343,195355,195364,195379,195397-195399,195408,195421,195423-195424,195432,195439,195444,195455-195456,195469,195476-195477,195479,195491-195493,195514,195528,195547,195567,195573-195576,195591,195599,195632,195635-195636,195670,195679,195682,195684,195713,195716,195769,195773,195779,195782,195787,195791,195798,195827,195834,195887
Modified: llvm/branches/release_34/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=195991&r1=195990&r2=195991&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/branches/release_34/lib/Transforms/Vectorize/LoopVectorize.cpp Sat Nov 30 21:03:42 2013
@@ -1537,6 +1537,15 @@ InnerLoopVectorizer::createEmptyLoop(Loo
const SCEV *ExitCount = SE->getBackedgeTakenCount(OrigLoop);
assert(ExitCount != SE->getCouldNotCompute() && "Invalid loop count");
+ // The exit count might have the type of i64 while the phi is i32. This can
+ // happen if we have an induction variable that is sign extended before the
+ // compare. The only way that we get a backedge taken count is that the
+ // induction variable was signed and as such will not overflow. In such a case
+ // truncation is legal.
+ if (ExitCount->getType()->getPrimitiveSizeInBits() >
+ IdxTy->getPrimitiveSizeInBits())
+ ExitCount = SE->getTruncateOrNoop(ExitCount, IdxTy);
+
ExitCount = SE->getNoopOrZeroExtend(ExitCount, IdxTy);
// Get the total trip count from the count by adding 1.
ExitCount = SE->getAddExpr(ExitCount,
More information about the llvm-branch-commits
mailing list