This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] sim: bfin: fix accumulator edge case saturation


From: Robin Getz <robin.getz@analog.com>

When the accumulator saturates, it needs to be greater than, but not
equal to, the largest unsigned value as this is what the hardware does.

Committed.

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>

2011-06-17  Robin Getz  <robin.getz@analog.com>

	* bfin-sim.c (saturate_s40_astat): Change ">" to ">=".
	(decode_macfunc): Likewise when mmod is M_IH.
---
 sim/bfin/bfin-sim.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c
index 1cdfd27..31136a0 100644
--- a/sim/bfin/bfin-sim.c
+++ b/sim/bfin/bfin-sim.c
@@ -1398,7 +1398,7 @@ saturate_s40_astat (bu64 val, bu32 *v)
       *v = 1;
       return -((bs64)1 << 39);
     }
-  else if ((bs64)val >= ((bs64)1 << 39) - 1)
+  else if ((bs64)val > ((bs64)1 << 39) - 1)
     {
       *v = 1;
       return ((bu64)1 << 39) - 1;
@@ -1645,7 +1645,7 @@ decode_macfunc (SIM_CPU *cpu, int which, int op, int h0, int h1, int src0,
 	case M_IH:
 	  if ((bs64)acc < -0x80000000ll)
 	    acc = -0x80000000ull, sat = 1;
-	  else if ((bs64)acc >= 0x7fffffffll)
+	  else if ((bs64)acc > 0x7fffffffll)
 	    acc = 0x7fffffffull, sat = 1;
 	  break;
 	case M_W32:
-- 
1.7.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]