// its simpler value.
if (Value *V = SimplifyInstruction(Inst, DL, &TLI, &DT, &AC)) {
DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n');
+ bool Killed = false;
if (!Inst->use_empty()) {
Inst->replaceAllUsesWith(V);
Changed = true;
if (isInstructionTriviallyDead(Inst, &TLI)) {
Inst->eraseFromParent();
Changed = true;
+ Killed = true;
}
- if (Changed) {
+ if (Changed)
++NumSimplify;
+ if (Killed)
continue;
- }
}
// If this is a simple instruction that we can value number, process it.
ret void
}
+@c = external global i32, align 4
+declare i32 @reads_c(i32 returned)
+define void @pr28763() {
+entry:
+; CHECK-LABEL: @pr28763(
+; CHECK: store i32 0, i32* @c, align 4
+; CHECK: call i32 @reads_c(i32 0)
+; CHECK: store i32 2, i32* @c, align 4
+ %load = load i32, i32* @c, align 4
+ store i32 0, i32* @c, align 4
+ %call = call i32 @reads_c(i32 0)
+ store i32 2, i32* @c, align 4
+ ret void
+}