diff options
author | Fraser Cormack <fraser@codeplay.com> | 2015-08-10 14:48:47 +0000 |
---|---|---|
committer | Fraser Cormack <fraser@codeplay.com> | 2015-08-10 14:48:47 +0000 |
commit | e29ab2bfabd12d06214a4a516ea9a2d44b5f1a0b (patch) | |
tree | 634d99fc10b32962a3e3a1916b64ecd7101074e8 /llvm/lib/Transforms/Scalar/Scalarizer.cpp | |
parent | 94515abfd743a965cff9799979fcb72364f863b7 (diff) | |
download | bcm5719-llvm-e29ab2bfabd12d06214a4a516ea9a2d44b5f1a0b.tar.gz bcm5719-llvm-e29ab2bfabd12d06214a4a516ea9a2d44b5f1a0b.zip |
Prevent the scalarizer from caching incorrect entries
The scalarizer can cache incorrect entries when walking up a chain of
insertelement instructions. This occurs when it encounters more than one
instruction that it is not actively searching for, as it unconditionally caches
every element it finds. The fix is to only cache the first element that it
isn't searching for so we don't overwrite correct entries.
Reviewers: hfinkel
Differential Revision: http://reviews.llvm.org/D11559
llvm-svn: 244448
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Scalarizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Scalarizer.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp index 3b8307c4316..c99f13be6a9 100644 --- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp +++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp @@ -227,10 +227,16 @@ Value *Scatterer::operator[](unsigned I) { if (!Idx) break; unsigned J = Idx->getZExtValue(); - CV[J] = Insert->getOperand(1); V = Insert->getOperand(0); - if (I == J) + if (I == J) { + CV[J] = Insert->getOperand(1); return CV[J]; + } else if (!CV[J]) { + // Only cache the first entry we find for each index we're not actively + // searching for. This prevents us from going too far up the chain and + // caching incorrect entries. + CV[J] = Insert->getOperand(1); + } } CV[I] = Builder.CreateExtractElement(V, Builder.getInt32(I), V->getName() + ".i" + Twine(I)); |