From f72c19e482b6f918b7cf42b0436e2b117d160a29 Mon Sep 17 00:00:00 2001
From: Mike Pall <mike>
Date: Fri, 22 Sep 2023 21:04:22 +0200
Subject: Maintain chain invariant in DCE.

Thanks to Peter Cawley. #1094
---
 src/lj_opt_dce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lj_opt_dce.c b/src/lj_opt_dce.c
index c6c3e1bc..e6fcc552 100644
--- a/src/lj_opt_dce.c
+++ b/src/lj_opt_dce.c
@@ -44,12 +44,12 @@ static void dce_propagate(jit_State *J)
     IRIns *ir = IR(ins);
     if (irt_ismarked(ir->t)) {
       irt_clearmark(ir->t);
-      pchain[ir->o] = &ir->prev;
     } else if (!ir_sideeff(ir)) {
       *pchain[ir->o] = ir->prev;  /* Reroute original instruction chain. */
       lj_ir_nop(ir);
       continue;
     }
+    pchain[ir->o] = &ir->prev;
     if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t);
     if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t);
   }
-- 
cgit v1.2.3-55-g6feb