[llvm-branch-commits] [llvm-branch] r309595 - Merging r309330:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 31 10:47:41 PDT 2017
Author: hans
Date: Mon Jul 31 10:47:41 2017
New Revision: 309595
URL: http://llvm.org/viewvc/llvm-project?rev=309595&view=rev
Log:
Merging r309330:
------------------------------------------------------------------------
r309330 | davide | 2017-07-27 15:20:44 -0700 (Thu, 27 Jul 2017) | 13 lines
[ConstantFolder] Don't try to fold gep when the idx is a vector.
The code in ConstantFoldGetElementPtr() assumes integers, and
therefore it crashes trying to get the integer bidwith of a vector
type (in this case <4 x i32>. I just changed the code to prevent
the folding in case of vectors and I didn't bother to generalize
as this doesn't seem to me something that really happens in
practice, but I'm willing to change the patch if you think
it's worth it.
This is hard to trigger from -instsimplify or -instcombine
only as the second instruction is dead, so the test uses loop-unroll.
Differential Revision: https://reviews.llvm.org/D35956
------------------------------------------------------------------------
Added:
llvm/branches/release_50/test/Transforms/InstSimplify/pr33957.ll
- copied unchanged from r309330, llvm/trunk/test/Transforms/InstSimplify/pr33957.ll
Modified:
llvm/branches/release_50/ (props changed)
llvm/branches/release_50/lib/IR/ConstantFold.cpp
Propchange: llvm/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 31 10:47:41 2017
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,308483-308484,308503,308808,308813,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309343,309353,309355,309422,309481,309483
+/llvm/trunk:155241,308483-308484,308503,308808,308813,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309330,309343,309353,309355,309422,309481,309483
Modified: llvm/branches/release_50/lib/IR/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/IR/ConstantFold.cpp?rev=309595&r1=309594&r2=309595&view=diff
==============================================================================
--- llvm/branches/release_50/lib/IR/ConstantFold.cpp (original)
+++ llvm/branches/release_50/lib/IR/ConstantFold.cpp Mon Jul 31 10:47:41 2017
@@ -2097,15 +2097,19 @@ Constant *llvm::ConstantFoldGetElementPt
// Subsequent evaluation would get confused and produce erroneous results.
//
// The following prohibits such a GEP from being formed by checking to see
- // if the index is in-range with respect to an array or vector.
+ // if the index is in-range with respect to an array.
+ // TODO: This code may be extended to handle vectors as well.
bool PerformFold = false;
if (Idx0->isNullValue())
PerformFold = true;
else if (LastI.isSequential())
if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx0))
- PerformFold =
- !LastI.isBoundedSequential() ||
- isIndexInRangeOfArrayType(LastI.getSequentialNumElements(), CI);
+ PerformFold = (!LastI.isBoundedSequential() ||
+ isIndexInRangeOfArrayType(
+ LastI.getSequentialNumElements(), CI)) &&
+ !CE->getOperand(CE->getNumOperands() - 1)
+ ->getType()
+ ->isVectorTy();
if (PerformFold) {
SmallVector<Value*, 16> NewIndices;
More information about the llvm-branch-commits
mailing list