aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-07 00:22:55 -0500
committerMike Frysinger <vapier@gentoo.org>2024-01-08 20:01:45 -0500
commitb0c687b2ca6e5910b0494c80d01d6b48ff6f0c51 (patch)
tree024c7255fdb017b42ab088bfa15719dd812b8226 /sim
parentb2ea48df925a6d41f63e88b26dbf3f17cde0f252 (diff)
downloadbinutils-b0c687b2ca6e5910b0494c80d01d6b48ff6f0c51.zip
binutils-b0c687b2ca6e5910b0494c80d01d6b48ff6f0c51.tar.gz
binutils-b0c687b2ca6e5910b0494c80d01d6b48ff6f0c51.tar.bz2
sim: bfin: avoid left shifting negative values
We just want to create a bitmask here, so cast the mask to unsigned to avoid left shifting a negative value which is undefined behavior.
Diffstat (limited to 'sim')
-rw-r--r--sim/bfin/bfin-sim.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c
index 1a9b499..2e7a563 100644
--- a/sim/bfin/bfin-sim.c
+++ b/sim/bfin/bfin-sim.c
@@ -786,7 +786,7 @@ lshift (SIM_CPU *cpu, bu64 val, int cnt, int size, bool saturate, bool overflow)
However, it's a little more complex than looking at sign bits, we need
to see if we are shifting the sign information away... */
if (((val << cnt) >> size) == 0
- || (((val << cnt) >> size) == ~(~0 << cnt)
+ || (((val << cnt) >> size) == ~((bu32)~0 << cnt)
&& ((new_val >> (size - 1)) & 0x1)))
v_i = 0;
else
@@ -5880,7 +5880,7 @@ decode_dsp32shiftimm_0 (SIM_CPU *cpu, bu16 iw0, bu16 iw1)
bu16 inshift = in << shift;
if (((inshift & ~0xFFFF)
- && ((inshift & ~0xFFFF) >> 16) != ~(~0 << shift))
+ && ((inshift & ~0xFFFF) >> 16) != ~((bu32)~0 << shift))
|| (inshift & 0x8000) != (in & 0x8000))
{
if (in & 0x8000)