diff --git a/c-opopt.cc b/c-opopt.cc index 06679a8..d5a8344 100644 --- a/c-opopt.cc +++ b/c-opopt.cc @@ -1503,7 +1503,7 @@ bool opopt::PropagateConstants( T_Set< uint32_t > cDefs{ UseTag< ArrayBacked< 16 > >( ) }; T_AutoArray< double , 16 > cValues; bool changesMade{ false }; - for ( auto const& udc : oData.varUDChains.values( ) ) { + for ( auto& udc : oData.varUDChains.values( ) ) { cDefs.clear( ); cValues.clear( ); @@ -1530,8 +1530,7 @@ bool opopt::PropagateConstants( continue; } - const auto nUses{ udc.uses.size( ) }; - for ( auto i = 0u ; i < nUses ; i ++ ) { + for ( auto i = 0u ; i < udc.uses.size( ) ; ) { auto const& use{ udc.uses[ i ] }; const auto nRefs{ use.refs.size( ) }; T_Optional< double > repVal{ }; @@ -1549,13 +1548,13 @@ bool opopt::PropagateConstants( } } if ( !repVal ) { + i ++; continue; } - printf( "Could replace use at %d with constant %f\n" , - use.node , *repVal ); CPReplaceWithConstant_( *oData.instructions[ use.node ].node , udc.var , *repVal , oData ); + udc.uses.removeSwap( i ); changesMade = true; } }