changeset 15246:4c0cef65c55f

pt-jit.cc (jit_infer::do_construct_ir): Correct extraious phi removal
author Max Brister <max@2bass.com>
date Tue, 28 Aug 2012 17:12:37 -0600
parents c16357c4bdbb
children fa8f3955e70a
files libinterp/interp-core/pt-jit.cc
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interp-core/pt-jit.cc
+++ b/libinterp/interp-core/pt-jit.cc
@@ -1287,17 +1287,16 @@
         {
           jit_phi *phi = static_cast<jit_phi *> (*iter);
           jit_variable *var = phi->dest ();
+          ++iter;
+
           if (var->has_top ())
-            {
-              phi->add_incomming (&ablock, var->top ());
-              ++iter;
-            }
+            phi->add_incomming (&ablock, var->top ());
           else
             {
               // temporaries may have extranious phi nodes which can be removed
               assert (! phi->use_count ());
               assert (var->name ().size () && var->name ()[0] == '#');
-              iter = finish->remove (iter);
+              phi->remove ();
             }
         }
     }
@@ -2042,4 +2041,15 @@
 
 %!assert (bubble (), [1 2 3]);
 
+%!test
+%! a = 0;
+%! b = 1;
+%! for i=1:1e3
+%!   for j=1:2
+%!     a = a + b;
+%!   endfor
+%! endfor
+%! assert (a, 2000);
+%! assert (b, 1);
+
 */