diff --git a/backends/asm/optimize_ir.c b/backends/asm/optimize_ir.c index 4e726f6c8..73911ef65 100644 --- a/backends/asm/optimize_ir.c +++ b/backends/asm/optimize_ir.c @@ -3710,7 +3710,7 @@ OptimizePeepholes(IRList *irl) if (test_is_z && InstrUsesFlags(testir, FLAG_WC)) { changeok = false; } else if (InstrSetsAnyFlags(testir)) { - changeok = sawir; + changeok = sawir && (test_is_c || !FlagsUsedAt(testir,FLAG_WZ)); lastir = testir; break; } @@ -3726,7 +3726,7 @@ OptimizePeepholes(IRList *irl) { ReplaceZWithNC(testir); } - if (IsBranch(lastir)) { + if (lastir != NULL && IsBranch(lastir)) { ReplaceZWithNC(lastir); } }