- size = 1 + compiler->saveds;
-#ifndef _WIN64
- if (compiler->saveds >= 2)
- size += compiler->saveds - 1;
-#else
- if (compiler->saveds >= 4)
- size += compiler->saveds - 3;
- if (compiler->scratches >= 5)
- size += (5 - 4) * 2;
-#endif
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
-
- INC_SIZE(size);
-
-#ifdef _WIN64
- if (compiler->scratches >= 5) {
- *inst++ = REX_B;
- POP_REG(reg_lmap[SLJIT_TEMPORARY_EREG2]);
- }
-#endif
- if (compiler->saveds >= 1)
- POP_REG(reg_map[SLJIT_SAVED_REG1]);
- if (compiler->saveds >= 2) {
-#ifndef _WIN64
- *inst++ = REX_B;
-#endif
- POP_REG(reg_lmap[SLJIT_SAVED_REG2]);
- }
- if (compiler->saveds >= 3) {
-#ifndef _WIN64
- *inst++ = REX_B;
-#endif
- POP_REG(reg_lmap[SLJIT_SAVED_REG3]);
- }
- if (compiler->saveds >= 4) {
- *inst++ = REX_B;
- POP_REG(reg_lmap[SLJIT_SAVED_EREG1]);
+ tmp = compiler->scratches;
+ for (i = SLJIT_FIRST_SAVED_REG; i <= tmp; i++) {
+ size = reg_map[i] >= 8 ? 2 : 1;
+ inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
+ FAIL_IF(!inst);
+ INC_SIZE(size);
+ if (reg_map[i] >= 8)
+ *inst++ = REX_B;
+ POP_REG(reg_lmap[i]);