From bd7edd27fda7e0549894c4ccac73b8b6d937ffdf Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Thu, 19 Aug 2021 10:58:03 -0700 Subject: [PATCH] flag loop that has slightly subtle logic --- src/script_opt/ZAM/AM-Opt.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/script_opt/ZAM/AM-Opt.cc b/src/script_opt/ZAM/AM-Opt.cc index 3bf273ebed..453a2403ab 100644 --- a/src/script_opt/ZAM/AM-Opt.cc +++ b/src/script_opt/ZAM/AM-Opt.cc @@ -155,8 +155,11 @@ bool ZAMCompiler::RemoveDeadCode() bool did_removal = false; - for ( auto& i0 : insts1 ) + // Note, loops up to the last instruction but not including it. + for ( unsigned int i = 0; i < insts1.size() - 1; ++i ) { + auto& i0 = insts1[i]; + if ( ! i0->live ) continue;