Skip to content

Commit 0dcb84b

Browse files
committed
Avoid saving FP-registers in variadic function if unnecessary on x64
1 parent 40f7d31 commit 0dcb84b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/cc/arch/x64/emit_x64.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,15 @@ static inline void move_params_to_assigned(Function *func) {
175175
MOV(kRegSizeTable[3][ArchRegParamMapping[i]], OFFSET_INDIRECT(offset, RBP, NULL, 1));
176176
}
177177
#ifndef __NO_FLONUM
178+
// If no value passed by FP registers, then skip saving them.
179+
const Name *skip_fp_save = alloc_label();
180+
TEST(AL, AL);
181+
JE(fmt_name(skip_fp_save));
178182
for (int i = reg_index[FPREG]; i < MAX_FREG_ARGS; ++i) {
179183
int offset = (i - MAX_FREG_ARGS) * TARGET_POINTER_SIZE;
180184
MOVSD(kFRegParam64s[i], OFFSET_INDIRECT(offset, RBP, NULL, 1));
181185
}
186+
EMIT_LABEL(fmt_name(skip_fp_save));
182187
#endif
183188
}
184189
#undef kFRegParam64s

0 commit comments

Comments
 (0)