summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-12-11 21:15:27 +0000
committerHans Wennborg <hans@hanshq.net>2017-12-11 21:15:27 +0000
commit27d1c00c0174845d8807f26aeedea07387bd127b (patch)
tree53b1859dd519e537670aa5d6f9d717998d7bd07a /llvm/lib
parent54be62df3954a25aa233c90b17c9c97ace079225 (diff)
downloadbcm5719-llvm-27d1c00c0174845d8807f26aeedea07387bd127b.tar.gz
bcm5719-llvm-27d1c00c0174845d8807f26aeedea07387bd127b.zip
Revert r320407 "[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast."
The tests fail (opt asserts) on Windows. > Summary: > If we have pattern `store (load(bitcast(select (cmp(V1, V2), &V1, > &V2)))), bitcast)`, but the load is used in other instructions, it leads > to looping in InstCombiner. Patch adds additional check that all users > of the load instructions are stores and then replaces all uses of load > instruction by the new one with new type. > > Reviewers: RKSimon, spatel, majnemer > > Subscribers: llvm-commits > > Differential Revision: https://reviews.llvm.org/D41072 llvm-svn: 320421
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index a729981a549..29e0a091aa7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -1344,24 +1344,9 @@ bool removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC, StoreInst &SI) {
if (!isMinMaxWithLoads(LoadAddr))
return false;
- if (!all_of(LI->users(), [LI](User *U) {
- auto *SI = dyn_cast<StoreInst>(U);
- return SI && SI->getPointerOperand() != LI &&
- !SI->getPointerOperand()->isSwiftError();
- }))
- return false;
-
- IC.Builder.SetInsertPoint(LI);
LoadInst *NewLI = combineLoadToNewType(
IC, *LI, LoadAddr->getType()->getPointerElementType());
- // Replace all the stores with stores of the newly loaded value.
- for (auto *UI : LI->users()) {
- auto *SI = cast<StoreInst>(UI);
- IC.Builder.SetInsertPoint(SI);
- combineStoreToNewValue(IC, *SI, NewLI);
- IC.eraseInstFromFunction(*SI);
- }
- IC.eraseInstFromFunction(*LI);
+ combineStoreToNewValue(IC, SI, NewLI);
return true;
}
@@ -1390,7 +1375,7 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
return eraseInstFromFunction(SI);
if (removeBitcastsFromLoadStoreOnMinMax(*this, SI))
- return nullptr;
+ return eraseInstFromFunction(SI);
// Replace GEP indices if possible.
if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI)) {
OpenPOWER on IntegriCloud