summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAmjad Aboud <amjad.aboud@intel.com>2018-01-31 22:39:05 +0000
committerAmjad Aboud <amjad.aboud@intel.com>2018-01-31 22:39:05 +0000
commitb86b771c020725e7f2113898e841a6f29b919548 (patch)
treed1c7f74955f6b923527e526cd4876d628c089f13 /llvm/lib
parente44faf53c769bf444aaf81358f85e46e26dd1d46 (diff)
downloadbcm5719-llvm-b86b771c020725e7f2113898e841a6f29b919548.tar.gz
bcm5719-llvm-b86b771c020725e7f2113898e841a6f29b919548.zip
[AggressiveInstCombine] Fixed TruncCombine class to handle TruncInst leaf node correctly.
This covers the case where TruncInst leaf node is a constant expression. See PR36121 for more details. Differential Revision: https://reviews.llvm.org/D42622 llvm-svn: 323926
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
index 0378ea79ef7..d62b6434f00 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
@@ -317,6 +317,7 @@ void TruncInstCombine::ReduceExpressionDag(Type *SclTy) {
// just return the source. There's no need to insert it because it is not
// new.
if (I->getOperand(0)->getType() == Ty) {
+ assert(!isa<TruncInst>(I) && "Cannot reach here with TruncInst");
NodeInfo.NewValue = I->getOperand(0);
continue;
}
@@ -326,11 +327,18 @@ void TruncInstCombine::ReduceExpressionDag(Type *SclTy) {
Opc == Instruction::SExt);
// Update Worklist entries with new value if needed.
- if (auto *NewCI = dyn_cast<TruncInst>(Res)) {
- auto Entry = find(Worklist, I);
- if (Entry != Worklist.end())
+ // There are three possible changes to the Worklist:
+ // 1. Update Old-TruncInst -> New-TruncInst.
+ // 2. Remove Old-TruncInst (if New node is not TruncInst).
+ // 3. Add New-TruncInst (if Old node was not TruncInst).
+ auto Entry = find(Worklist, I);
+ if (Entry != Worklist.end()) {
+ if (auto *NewCI = dyn_cast<TruncInst>(Res))
*Entry = NewCI;
- }
+ else
+ Worklist.erase(Entry);
+ } else if (auto *NewCI = dyn_cast<TruncInst>(Res))
+ Worklist.push_back(NewCI);
break;
}
case Instruction::Add:
OpenPOWER on IntegriCloud