summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-12-12 19:12:34 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-12-12 19:12:34 +0000
commitfa0a76dbcc03e4059f6c43d7efdb977d1e07c975 (patch)
treed1d8bec2454e1b04052ca9c4bda86de87912259a /llvm/lib/Transforms
parent1074eb225b3726c5e67e35f4b5c7bbc3470955a9 (diff)
downloadbcm5719-llvm-fa0a76dbcc03e4059f6c43d7efdb977d1e07c975.tar.gz
bcm5719-llvm-fa0a76dbcc03e4059f6c43d7efdb977d1e07c975.zip
Revert "[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bitcast."
This reverts commit r320510 - again sanitizers bbots. llvm-svn: 320513
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp40
1 files changed, 11 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 5e4d32d6880..01fc1528681 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -1339,39 +1339,25 @@ static bool equivalentAddressValues(Value *A, Value *B) {
/// Converts store (bitcast (load (bitcast (select ...)))) to
/// store (load (select ...)), where select is minmax:
/// select ((cmp load V1, load V2), V1, V2).
-static Instruction *removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC,
- StoreInst &SI) {
+bool removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC, StoreInst &SI) {
// bitcast?
- if (!match(SI.getPointerOperand(), m_BitCast(m_Value())))
- return nullptr;
+ Value *StoreAddr;
+ if (!match(SI.getPointerOperand(), m_BitCast(m_Value(StoreAddr))))
+ return false;
// load? integer?
Value *LoadAddr;
if (!match(SI.getValueOperand(), m_Load(m_BitCast(m_Value(LoadAddr)))))
- return nullptr;
+ return false;
auto *LI = cast<LoadInst>(SI.getValueOperand());
if (!LI->getType()->isIntegerTy())
- return nullptr;
+ return false;
if (!isMinMaxWithLoads(LoadAddr))
- return nullptr;
-
- if (!all_of(LI->users(), [LI, LoadAddr](User *U) {
- auto *SI = dyn_cast<StoreInst>(U);
- return SI && SI->getPointerOperand() != LI &&
- peekThroughBitcast(SI->getPointerOperand()) != LoadAddr &&
- !SI->getPointerOperand()->isSwiftError();
- }))
- return nullptr;
+ 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 *USI = cast<StoreInst>(UI);
- IC.Builder.SetInsertPoint(USI);
- combineStoreToNewValue(IC, *USI, NewLI);
- }
- return LI;
+ combineStoreToNewValue(IC, SI, NewLI);
+ return true;
}
Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
@@ -1398,12 +1384,8 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
if (unpackStoreToAggregate(*this, SI))
return eraseInstFromFunction(SI);
- if (Instruction *I = removeBitcastsFromLoadStoreOnMinMax(*this, SI)) {
- for (auto *UI : I->users())
- eraseInstFromFunction(*cast<Instruction>(UI));
- eraseInstFromFunction(*I);
- return nullptr;
- }
+ if (removeBitcastsFromLoadStoreOnMinMax(*this, SI))
+ return eraseInstFromFunction(SI);
// Replace GEP indices if possible.
if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI)) {
OpenPOWER on IntegriCloud