diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-11-11 19:30:41 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-11-13 00:57:00 -0500 |
commit | dc5a4621600e650b89deb92c79eaacc73fcc767a (patch) | |
tree | 751639d6cd55b404a0ec0ccc03411649abfa7eb2 | |
parent | b9252d079a28c6da1b42e501217f25e8a6652321 (diff) | |
download | fsf-binutils-gdb-dc5a4621600e650b89deb92c79eaacc73fcc767a.zip fsf-binutils-gdb-dc5a4621600e650b89deb92c79eaacc73fcc767a.tar.gz fsf-binutils-gdb-dc5a4621600e650b89deb92c79eaacc73fcc767a.tar.bz2 |
sim: sh: rework carry checks to not rely on integer overflows
In <=gcc-7 versions, -fstrict-overflow is enabled by default, and that
triggers warnings in this code that relies on integer overflows to test
for carries. Change the logic to test against the limit directly.
-rw-r--r-- | sim/sh/gencode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 80eecfd..5eb7caf 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -2266,7 +2266,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx - 0x10000;", - "carry = res > Sx;", + "carry = Sx < (INT_MIN + 0x10000);", "res_grd = Sx_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2277,7 +2277,7 @@ op ppi_tab[] = "int Sx_grd = GET_DSP_GRD (x);", "", "res = Sx + 0x10000;", - "carry = res < Sx;", + "carry = Sx > (INT_MAX - 0x10000);", "res_grd = Sx_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2288,7 +2288,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy - 0x10000;", - "carry = res > Sy;", + "carry = Sy < (INT_MIN + 0x10000);", "res_grd = Sy_grd - carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", @@ -2299,7 +2299,7 @@ op ppi_tab[] = "int Sy_grd = SIGN32 (Sy);", "", "res = Sy + 0x10000;", - "carry = res < Sy;", + "carry = Sy > (INT_MAX - 0x10000);", "res_grd = Sy_grd + carry;", "COMPUTE_OVERFLOW;", "ADD_SUB_GE;", |