does `make check` pass ?  if not, that's a good reason to not merge
this change :).

if it does, i've got other fixes pending locally related to shifts, so
lemme see if i can find time this weekend to see if those also fix
this.
-mike

On Wed, Mar 14, 2012 at 13:44, Henderson, Stuart
<stuart.hender...@analog.com> wrote:
> A user recently pointed out the following bug in our simulator:
> [#7002] simulator bug with saturating shift
> where:
> R0 = -4(X);
> R1 = R0 <<31 (S);
> results in 0 instead of 0x80000000.
>
> The problem is we're not detecting the sign bit being shifted out of the 
> range of the register.  this happens when we're detecting the real shift 
> count.  we check if it's greater than 16, and if it is, shift the value by 16 
> and then decrement the shift count by 16.  I've no idea why we do this, 
> however, as we then go straight on to shift the value the rest of the way.  
> The only side effect of this being that the shift count is now 16 less than 
> it should be for when we're doing the overflow check later on.
> Unless someone can give me a good reason as to why this makes sense, I plan 
> to remove it.  This will fix the bug and doesn't appear to have any other 
> side effects, although I'm still testing.
>
> Thanks,
> Stu
>
>
> Index: binutils-2.17/sim/bfin/bfin-sim.c
> ===================================================================
> --- binutils-2.17/sim/bfin/bfin-sim.c   (revision 5800)
> +++ binutils-2.17/sim/bfin/bfin-sim.c   (working copy)
> @@ -760,9 +760,6 @@
>   sgn <<= mask_cnt;
>   masked = val & mask;
>
> -  if (real_cnt > 16)
> -    new_val <<= 16, real_cnt -= 16;
> -
>   new_val <<= real_cnt;
>
>   masked = new_val & mask;
>
>
>
> _______________________________________________
> Toolchain-devel mailing list
> Toolchain-devel@blackfin.uclinux.org
> https://blackfin.uclinux.org/mailman/listinfo/toolchain-devel
_______________________________________________
Toolchain-devel mailing list
Toolchain-devel@blackfin.uclinux.org
https://blackfin.uclinux.org/mailman/listinfo/toolchain-devel

Reply via email to