From: Mike Pall Date: Wed, 14 Aug 2024 22:07:34 +0000 (+0200) Subject: Limit CSE for IR_CARG to fix loop optimizations. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bdc6498c4c012a8fbf9cfa2756a5b07f56f1540;p=thirdparty%2FLuaJIT.git Limit CSE for IR_CARG to fix loop optimizations. Thanks to Peter Cawley. #1244 --- diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c index b437d672..98ec28c6 100644 --- a/src/lj_opt_fold.c +++ b/src/lj_opt_fold.c @@ -2171,6 +2171,17 @@ LJFOLD(CNEW any any) LJFOLD(XSNEW any any) LJFOLDX(lj_ir_emit) +/* -- Miscellaneous ------------------------------------------------------- */ + +LJFOLD(CARG any any) +LJFOLDF(cse_carg) +{ + TRef tr = lj_opt_cse(J); + if (tref_ref(tr) < J->chain[IR_LOOP]) /* CSE across loop? */ + return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */ + return tr; +} + /* ------------------------------------------------------------------------ */ /* Every entry in the generated hash table is a 32 bit pattern: