@@ -1395,25 +1395,44 @@ L3:
13951395/* *************************
13961396 * Generate a MOV to,from register instruction.
13971397 * Smart enough to dump redundant register moves, and segment
1398- * register moves.
1398+ * register moves. No conversions are done.
1399+ * Params:
1400+ * cdb = code sink
1401+ * to = destination register
1402+ * from = source register
1403+ * ty = type, TYMAX means use full register
13991404 */
14001405
14011406@trusted
14021407void genmovreg (ref CodeBuilder cdb, reg_t to, reg_t from, tym_t ty = TYMAX )
14031408{
14041409 if (to != from)
14051410 {
1406- if (mask(to ) & INSTR . FLOATREGS )
1411+ if (! ((to | from ) & 32 )) // both are gp registers
14071412 {
1408- // floating point
1409- uint ftype = INSTR .szToFtype(ty == TYMAX ? 8 : _tysize[ty]);
1410- cdb.gen1(INSTR .fmov(ftype, from & 31 , to & 31 ));
1413+ // integer
1414+ const uint sf = ty == TYMAX || _tysize[ty] == 8 ;
1415+ cdb.gen1(INSTR .mov_register(sf, from, to)); // MOV gp,gp https://www.scs.stanford.edu/~zyedidia/arm64/mov_orr_log_shift.html
1416+
14111417 }
1412- else
1418+ else // one or both are floating point registers
14131419 {
1414- // integer
1415- uint sf = ty == TYMAX || _tysize[ty] == 8 ;
1416- cdb.gen1(INSTR .mov_register(sf, from, to)); // MOV to,from
1420+ const uint ftype = INSTR .szToFtype(ty == TYMAX ? 8 : _tysize[ty]);
1421+ if (to & from & 32 ) // both are fp registers
1422+ {
1423+ // floating point
1424+ cdb.gen1(INSTR .fmov(ftype, from, to)); // FMOV fp,fp https://www.scs.stanford.edu/~zyedidia/arm64/fmov_float.html
1425+ }
1426+ else if ((to & 32 ) && ! (from & 32 ))
1427+ {
1428+ cdb.gen1(INSTR .fmov_float_gen(1 ,ftype,0 ,7 ,from,to)); // FMOV fp,gp https://www.scs.stanford.edu/~zyedidia/arm64/fmov_float_gen.html
1429+ }
1430+ else if (! (to & 32 ) && (from & 32 ))
1431+ {
1432+ cdb.gen1(INSTR .fmov_float_gen(1 ,ftype,0 ,6 ,from,to)); // FMOV gp,fp https://www.scs.stanford.edu/~zyedidia/arm64/fmov_float_gen.html
1433+ }
1434+ else
1435+ assert (0 );
14171436 }
14181437 }
14191438}
0 commit comments