@@ -71,6 +71,7 @@ typedef struct ASMState {
7171 IRRef snaprename ; /* Rename highwater mark for snapshot check. */
7272 SnapNo snapno ; /* Current snapshot number. */
7373 SnapNo loopsnapno ; /* Loop snapshot number. */
74+ BloomFilter snapfilt1 , snapfilt2 ; /* Filled with snapshot refs. */
7475
7576 IRRef fuseref ; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */
7677 IRRef sectref ; /* Section base reference (loopref or 0). */
@@ -825,7 +826,10 @@ static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs)
825826static void asm_snap_alloc1 (ASMState * as , IRRef ref )
826827{
827828 IRIns * ir = IR (ref );
828- if (!irref_isk (ref ) && (!(ra_used (ir ) || ir -> r == RID_SUNK ))) {
829+ if (!irref_isk (ref ) && ir -> r != RID_SUNK ) {
830+ bloomset (as -> snapfilt1 , ref );
831+ bloomset (as -> snapfilt2 , hashrot (ref , ref + HASH_BIAS ));
832+ if (ra_used (ir )) return ;
829833 if (ir -> r == RID_SINK ) {
830834 ir -> r = RID_SUNK ;
831835#if LJ_HASFFI
@@ -882,6 +886,7 @@ static void asm_snap_alloc(ASMState *as)
882886 SnapShot * snap = & as -> T -> snap [as -> snapno ];
883887 SnapEntry * map = & as -> T -> snapmap [snap -> mapofs ];
884888 MSize n , nent = snap -> nent ;
889+ as -> snapfilt1 = as -> snapfilt2 = 0 ;
885890 for (n = 0 ; n < nent ; n ++ ) {
886891 SnapEntry sn = map [n ];
887892 IRRef ref = snap_ref (sn );
@@ -904,18 +909,12 @@ static void asm_snap_alloc(ASMState *as)
904909*/
905910static int asm_snap_checkrename (ASMState * as , IRRef ren )
906911{
907- SnapShot * snap = & as -> T -> snap [as -> snapno ];
908- SnapEntry * map = & as -> T -> snapmap [snap -> mapofs ];
909- MSize n , nent = snap -> nent ;
910- for (n = 0 ; n < nent ; n ++ ) {
911- SnapEntry sn = map [n ];
912- IRRef ref = snap_ref (sn );
913- if (ref == ren || (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM ) && ++ ref == ren )) {
914- IRIns * ir = IR (ref );
915- ra_spill (as , ir ); /* Register renamed, so force a spill slot. */
916- RA_DBGX ((as , "snaprensp $f $s" , ref , ir -> s ));
917- return 1 ; /* Found. */
918- }
912+ if (bloomtest (as -> snapfilt1 , ren ) &&
913+ bloomtest (as -> snapfilt2 , hashrot (ren , ren + HASH_BIAS ))) {
914+ IRIns * ir = IR (ren );
915+ ra_spill (as , ir ); /* Register renamed, so force a spill slot. */
916+ RA_DBGX ((as , "snaprensp $f $s" , ren , ir -> s ));
917+ return 1 ; /* Found. */
919918 }
920919 return 0 ; /* Not found. */
921920}
0 commit comments