diff options
author | Peter Collingbourne <pcc@google.com> | 2021-01-25 13:10:37 -0800 |
---|---|---|
committer | Jacob Bramley <jacob.bramley@arm.com> | 2021-02-03 11:37:23 +0000 |
commit | 852d12ca548919a23a3dbeb32751552ce0ad50f3 (patch) | |
tree | 2bcc19ac6d7e1251ab8e9b4ded022e3d18abe19a | |
parent | 21d46841c815c01d60ec267ea3d812b83fc1f1b1 (diff) |
Fix clang build.dev/fix-clang
Clang warns (and errors due to -Werror) about these comparisons
losing precision as a result of the constants kXMaxInt and kXMaxUInt
being unrepresentable as a double. Although the warning could be
silenced by explicitly casting the constants to doubles, this relies
on implementation-defined rounding behavior so just write out the
floating point literals explicitly.
-rw-r--r-- | src/aarch64/logic-aarch64.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/aarch64/logic-aarch64.cc b/src/aarch64/logic-aarch64.cc index cb82f715..de77e58a 100644 --- a/src/aarch64/logic-aarch64.cc +++ b/src/aarch64/logic-aarch64.cc @@ -4755,7 +4755,9 @@ int32_t Simulator::FPToInt32(double value, FPRounding rmode) { int64_t Simulator::FPToInt64(double value, FPRounding rmode) { value = FPRoundInt(value, rmode); - if (value >= kXMaxInt) { + // This is equivalent to "if (value >= kXMaxInt)" but avoids rounding issues + // as a result of kMaxInt not being representable as a double. + if (value >= 9223372036854775808.) { return kXMaxInt; } else if (value < kXMinInt) { return kXMinInt; @@ -4788,7 +4790,9 @@ uint32_t Simulator::FPToUInt32(double value, FPRounding rmode) { uint64_t Simulator::FPToUInt64(double value, FPRounding rmode) { value = FPRoundInt(value, rmode); - if (value >= kXMaxUInt) { + // This is equivalent to "if (value >= kXMaxUInt)" but avoids rounding issues + // as a result of kMaxUInt not being representable as a double. + if (value >= 18446744073709551616.) { return kXMaxUInt; } else if (value < 0.0) { return 0; |