target-sh4: improve shld instruction
commit577601616dea10db10a716de1be448f8564076f4
authorAurelien Jarno <aurelien@aurel32.net>
Sun, 5 Jul 2015 20:37:18 +0000 (5 22:37 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 13 Sep 2015 21:08:51 +0000 (13 23:08 +0200)
tree6b493b6120f0481fd2b03801456d1382d4cc9114
parenteb6ca2b4a69325e95526bc0f2897791df04e44dc
target-sh4: improve shld instruction

The SH4 shld instruction can shift in both direction, depending on the
sign of the shift. This is currently implemented using branches, which
is not really efficient and prevents the optimizer to do its job. In
practice it is often used with a constant loaded in a register just
before.

Simplify the implementation by computing both the value shifted to the
left and to the right, and then selecting the correct one with a
movcond. As with a negative value the shift amount can go up to 32 which
is undefined, we shift the value in two steps.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-sh4/translate.c