]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Add stricter check for sinking PHIs.
authorMike Pall <mike>
Wed, 4 Jul 2012 09:41:58 +0000 (11:41 +0200)
committerMike Pall <mike>
Wed, 4 Jul 2012 09:41:58 +0000 (11:41 +0200)
src/lj_opt_sink.c

index 070970cad6733e32d0069e0637d66097883cc6a6..937cccc7a040f12fa6b0cac99ea9886017e85b7a 100644 (file)
@@ -47,7 +47,7 @@ static int sink_phidep(jit_State *J, IRRef ref)
   return 0;
 }
 
-/* Check whether a value is a sinkable PHI or a non-PHI. */
+/* Check whether a value is a sinkable PHI or loop-invariant. */
 static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref)
 {
   if (ref >= REF_FIRST) {
@@ -57,7 +57,8 @@ static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref)
       ira->prev++;
       return 1;  /* Sinkable PHI. */
     }
-    return !sink_phidep(J, ref);  /* Must be a non-PHI then. */
+    /* Otherwise the value must be loop-invariant. */
+    return ref < J->loopref && !sink_phidep(J, ref);
   }
   return 1;  /* Constant (non-PHI). */
 }