Skip to content

Commit

Permalink
Revert "[InstCombine] Fix infinite loop due to bitcast <-> phi transf…
Browse files Browse the repository at this point in the history
…orms" (llvm#35)

This reverts commit 8813358, which was
incorrect without dependent changes.
  • Loading branch information
tmandry authored and cuviper committed Jan 17, 2020
1 parent 97dab12 commit 3121697
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 200 deletions.
11 changes: 3 additions & 8 deletions llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2234,14 +2234,9 @@ Instruction *InstCombiner::optimizeBitCastFromPhi(CastInst &CI, PHINode *PN) {
if (auto *C = dyn_cast<Constant>(V)) {
NewV = ConstantExpr::getBitCast(C, DestTy);
} else if (auto *LI = dyn_cast<LoadInst>(V)) {
// Explicitly perform load combine to make sure no opposing transform
// can remove the bitcast in the meantime and trigger an infinite loop.
Builder.SetInsertPoint(LI);
NewV = combineLoadToNewType(*LI, DestTy);
// Remove the old load and its use in the old phi, which itself becomes
// dead once the whole transform finishes.
replaceInstUsesWith(*LI, UndefValue::get(LI->getType()));
eraseInstFromFunction(*LI);
Builder.SetInsertPoint(LI->getNextNode());
NewV = Builder.CreateBitCast(LI, DestTy);
Worklist.Add(LI);
} else if (auto *BCI = dyn_cast<BitCastInst>(V)) {
NewV = BCI->getOperand(0);
} else if (auto *PrevPN = dyn_cast<PHINode>(V)) {
Expand Down
192 changes: 0 additions & 192 deletions llvm/test/Transforms/InstCombine/pr44245.ll

This file was deleted.

0 comments on commit 3121697

Please sign in to comment.