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.
This commit is contained in:
Mike Frysinger
2021-11-11 19:30:41 -05:00
parent b9252d079a
commit dc5a462160

View File

@@ -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;",