From 3f946aa82518e878aea2cba4b6a9bcc651412c5c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 11 Oct 2015 03:32:11 -0400 Subject: sim: bfin: handle negative left saturated shifts as ashifts [BZ #18407] When handling left saturated ashifts with negative immediates, they should be treated as right ashifts. This matches hardware behavior. Reported-by: Igor Rayak --- sim/bfin/bfin-sim.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sim/bfin/bfin-sim.c') diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c index 8b19ead..b6acb4e 100644 --- a/sim/bfin/bfin-sim.c +++ b/sim/bfin/bfin-sim.c @@ -6083,7 +6083,11 @@ decode_dsp32shiftimm_0 (SIM_CPU *cpu, bu16 iw0, bu16 iw1) int count = imm6 (immag); TRACE_INSN (cpu, "R%i = R%i << %i (S);", dst0, src1, count); - STORE (DREG (dst0), lshift (cpu, DREG (src1), count, 32, 1, 1)); + + if (count < 0) + STORE (DREG (dst0), ashiftrt (cpu, DREG (src1), -count, 32)); + else + STORE (DREG (dst0), lshift (cpu, DREG (src1), count, 32, 1, 1)); } else if (sop == 2 && sopcde == 2) { -- cgit v1.1