llvm.org GIT mirror llvm / b9ddc3d
[EarlyCSE] Correctly handle simplified, but live, instructions Some instructions may have their uses replaced with a symbolic constant. However, the instruction may still have side effects which percludes it from being removed from the function. EarlyCSE treated such an instruction as if it were removed, resulting in PR28763. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277114 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 3 years ago
2 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
581581 // its simpler value.
582582 if (Value *V = SimplifyInstruction(Inst, DL, &TLI, &DT, &AC)) {
583583 DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n');
584 bool Killed = false;
584585 if (!Inst->use_empty()) {
585586 Inst->replaceAllUsesWith(V);
586587 Changed = true;
588589 if (isInstructionTriviallyDead(Inst, &TLI)) {
589590 Inst->eraseFromParent();
590591 Changed = true;
591 }
592 if (Changed) {
592 Killed = true;
593 }
594 if (Changed)
593595 ++NumSimplify;
596 if (Killed)
594597 continue;
595 }
596598 }
597599
598600 // If this is a simple instruction that we can value number, process it.
275275 ret void
276276 }
277277
278 @c = external global i32, align 4
279 declare i32 @reads_c(i32 returned)
280 define void @pr28763() {
281 entry:
282 ; CHECK-LABEL: @pr28763(
283 ; CHECK: store i32 0, i32* @c, align 4
284 ; CHECK: call i32 @reads_c(i32 0)
285 ; CHECK: store i32 2, i32* @c, align 4
286 %load = load i32, i32* @c, align 4
287 store i32 0, i32* @c, align 4
288 %call = call i32 @reads_c(i32 0)
289 store i32 2, i32* @c, align 4
290 ret void
291 }