From 185ee9331230537c3571ade4384794992ef14d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1roly=20Balogh?= Date: Sun, 3 Jan 2016 18:32:27 +0000 Subject: [PATCH] m68k: if we're loading small (8 bit signed) values into long references, move them through a register (usually with MOVEQ). this is two bytes shorter and also faster on most 68k CPUs git-svn-id: trunk@32837 - --- compiler/m68k/cgcpu.pas | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 4514bcd7d1..fd9444547e 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -827,7 +827,18 @@ unit cgcpu; list.concat(taicpu.op_reg_ref(A_MOVE,tcgsize2opsize[tosize],hreg,href)); end else - list.concat(taicpu.op_const_ref(A_MOVE,tcgsize2opsize[tosize],longint(a),href)); + { loading via a register is almost always faster if the value is small. + (with the 68040 being the only notable exception, so maybe disable + this on a '040? but the difference is minor) it also results in shorter + code. (KB) } + if isvalue8bit(a) and (tcgsize2opsize[tosize] = S_L) then + begin + hreg:=getintregister(list,OS_INT); + a_load_const_reg(list,OS_INT,a,hreg); // this will use moveq et.al. + list.concat(taicpu.op_reg_ref(A_MOVE,tcgsize2opsize[tosize],hreg,href)); + end + else + list.concat(taicpu.op_const_ref(A_MOVE,tcgsize2opsize[tosize],longint(a),href)); end;