summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2016-08-31 17:45:31 +0000
committerGeoff Berry <gberry@codeaurora.org>2016-08-31 17:45:31 +0000
commit64f5ed172a66f9687d1d70253b7faae2dd2064ba (patch)
treeacce435c75ac52d08173860a0bf4e1af3c79df91 /llvm/lib/Transforms/Scalar/EarlyCSE.cpp
parentc7f76104b35f8e30b10405cab374f12b1ac01473 (diff)
downloadbcm5719-llvm-64f5ed172a66f9687d1d70253b7faae2dd2064ba.tar.gz
bcm5719-llvm-64f5ed172a66f9687d1d70253b7faae2dd2064ba.zip
[EarlyCSE] Allow forwarding a non-invariant load into an invariant load.
Reviewers: sanjoy Subscribers: mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D23935 llvm-svn: 280265
Diffstat (limited to 'llvm/lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/EarlyCSE.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 0a8a7508c19..f57b89556fb 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -644,13 +644,13 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
// generation or the load is known to be from an invariant location,
// replace this instruction.
//
- // A dominating invariant load implies that the location loaded from is
- // unchanging beginning at the point of the invariant load, so the load
- // we're CSE'ing _away_ does not need to be invariant, only the available
- // load we're CSE'ing _to_ does.
+ // If either the dominating load or the current load are invariant, then
+ // we can assume the current load loads the same value as the dominating
+ // load.
LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand());
if (InVal.DefInst != nullptr &&
- (InVal.Generation == CurrentGeneration || InVal.IsInvariant) &&
+ (InVal.Generation == CurrentGeneration ||
+ InVal.IsInvariant || MemInst.isInvariantLoad()) &&
InVal.MatchingId == MemInst.getMatchingId() &&
// We don't yet handle removing loads with ordering of any kind.
!MemInst.isVolatile() && MemInst.isUnordered() &&
OpenPOWER on IntegriCloud