Optimizer - Update UD chains during constant propagation

This commit is contained in:
Emmanuel BENOîT 2017-12-14 18:46:36 +01:00
parent 12f9402c94
commit 312392d405

View file

@ -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;
}
}