Skip to content

Commit 3121697

Browse files
tmandrycuviper
authored andcommitted
Revert "[InstCombine] Fix infinite loop due to bitcast <-> phi transforms" (#35)
This reverts commit 8813358, which was incorrect without dependent changes.
1 parent 97dab12 commit 3121697

File tree

2 files changed

+3
-200
lines changed

2 files changed

+3
-200
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -2234,14 +2234,9 @@ Instruction *InstCombiner::optimizeBitCastFromPhi(CastInst &CI, PHINode *PN) {
22342234
if (auto *C = dyn_cast<Constant>(V)) {
22352235
NewV = ConstantExpr::getBitCast(C, DestTy);
22362236
} else if (auto *LI = dyn_cast<LoadInst>(V)) {
2237-
// Explicitly perform load combine to make sure no opposing transform
2238-
// can remove the bitcast in the meantime and trigger an infinite loop.
2239-
Builder.SetInsertPoint(LI);
2240-
NewV = combineLoadToNewType(*LI, DestTy);
2241-
// Remove the old load and its use in the old phi, which itself becomes
2242-
// dead once the whole transform finishes.
2243-
replaceInstUsesWith(*LI, UndefValue::get(LI->getType()));
2244-
eraseInstFromFunction(*LI);
2237+
Builder.SetInsertPoint(LI->getNextNode());
2238+
NewV = Builder.CreateBitCast(LI, DestTy);
2239+
Worklist.Add(LI);
22452240
} else if (auto *BCI = dyn_cast<BitCastInst>(V)) {
22462241
NewV = BCI->getOperand(0);
22472242
} else if (auto *PrevPN = dyn_cast<PHINode>(V)) {

llvm/test/Transforms/InstCombine/pr44245.ll

-192
This file was deleted.

0 commit comments

Comments
 (0)