Commits

Armin Rigo committed 99f12ac

Transplant 7a6bc2abea20

Comments (0)

Files changed (2)

rpython/jit/metainterp/optimizeopt/rewrite.py

         val = self.getvalue(arg)
         if val.is_constant():
             if val.box.same_constant(CONST_0):
+                self.last_emitted_operation = REMOVED
                 return
             op = op.copy_and_change(rop.CALL, args=op.getarglist()[1:])
         self.emit_operation(op)

rpython/jit/metainterp/test/test_call.py

         assert self.interp_operations(main, [10]) == 1
         assert self.interp_operations(main, [5]) == 0
 
+    def test_cond_call_disappears(self):
+        driver = jit.JitDriver(greens = [], reds = ['n'])
+
+        def f(n):
+            raise ValueError
+
+        def main(n):
+            while n > 0:
+                driver.jit_merge_point(n=n)
+                jit.conditional_call(False, f, 10)
+                n -= 1
+            return 42
+
+        assert self.meta_interp(main, [10]) == 42
+        self.check_resops(guard_no_exception=0)