RedundantFlagCalculationElimination: fix convergence issue

If both the destination and the flags are dead for an AddWithFlags, we need to
eliminate it in one pass. If we only replace without elimiating, we would need a
second DCE pass to eliminate. We want DCE to finish in one pass, so fix this.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig committed 2024-05-24 15:44:49 -04:00
1 parent 273d086a7b
commit cf77f2ae5d
1 file changed
+1 -1
@@ -362,7 +362,7 @@ void DeadFlagCalculationEliminination::Run(IREmitter* IREmit) {
bool Eliminated = false;
if ((FlagsRead & Info.Write) == 0) {
if (Info.CanEliminate && CodeNode->GetUses() == 0) {
if ((Info.CanEliminate || Info.CanReplace) && CodeNode->GetUses() == 0) {
IREmit->Remove(CodeNode);
Eliminated = true;
} else if (Info.CanReplace) {