@@ -118,7 +118,8 @@ RuntimeOptimizer::RuntimeOptimizer (ShadingSystemImpl &shadingsys,
118118 m_opt_middleman(shadingsys.m_opt_middleman),
119119 m_pass(0 ),
120120 m_next_newconst(0 ), m_next_newtemp(0 ),
121- m_stat_opt_locking_time(0 ), m_stat_specialization_time(0 )
121+ m_stat_opt_locking_time(0 ), m_stat_specialization_time(0 ),
122+ m_stop_optimizing(false )
122123{
123124 memset (&m_shaderglobals, 0 , sizeof (ShaderGlobals));
124125 m_shaderglobals.context = shadingcontext ();
@@ -1841,6 +1842,9 @@ RuntimeOptimizer::optimize_instance ()
18411842 if (m_pass != 0 && inst ()->unused ())
18421843 break ;
18431844
1845+ if (m_stop_optimizing)
1846+ break ;
1847+
18441848 // Track basic blocks and conditional states
18451849 find_conditionals ();
18461850 find_basic_blocks ();
@@ -1862,6 +1866,9 @@ RuntimeOptimizer::optimize_instance ()
18621866 size_t num_ops = inst ()->ops ().size ();
18631867 int skipops = 0 ; // extra inserted ops to skip over
18641868 for (int opnum = 0 ; opnum < (int )num_ops; opnum += 1 ) {
1869+ if (m_stop_optimizing)
1870+ break ;
1871+
18651872 // Before getting a reference to this op, be sure that a space
18661873 // is reserved at the end in case a folding routine inserts an
18671874 // op. That ensures that the reference won't be invalid.
@@ -2027,6 +2034,8 @@ RuntimeOptimizer::optimize_instance ()
20272034
20282035 if (optimize () >= 2 && m_opt_elide_useless_ops)
20292036 changed += useless_op_elision (op, opnum);
2037+ if (m_stop_optimizing)
2038+ break ;
20302039
20312040 // Peephole optimization involving pair of instructions
20322041 if (optimize () >= 2 && m_opt_peephole)
0 commit comments