Commit 8b48c59d authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[mips][Simulator] Fix some implicit conversion errors

Change-Id: Ide2aca9e7cbcd204a5668e59aa902bd2de363799
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3033842
Auto-Submit: Liu yu <liuyu@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/master@{#75750}
parent 9e9ed620
......@@ -1169,7 +1169,7 @@ void Simulator::set_fpu_register_invalid_result64(float original,
if (FCSR_ & kFCSRNaN2008FlagMask) {
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
if (std::isnan(original)) {
set_fpu_register(fd_reg(), 0);
......@@ -1228,7 +1228,7 @@ void Simulator::set_fpu_register_invalid_result64(double original,
if (FCSR_ & kFCSRNaN2008FlagMask) {
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
if (std::isnan(original)) {
set_fpu_register(fd_reg(), 0);
......@@ -1288,7 +1288,7 @@ bool Simulator::set_fcsr_round64_error(double original, double rounded) {
bool ret = false;
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
clear_fcsr_cause();
......@@ -1366,7 +1366,7 @@ bool Simulator::set_fcsr_round64_error(float original, float rounded) {
bool ret = false;
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
clear_fcsr_cause();
......@@ -5978,8 +5978,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_int min_int = std::numeric_limits<T_int>::min();
if (std::isnan(element)) {
*dst = 0;
} else if (element >= max_int || element <= min_int) {
*dst = element >= max_int ? max_int : min_int;
} else if (element >= static_cast<T_fp>(max_int) || element <= min_int) {
*dst = element >= static_cast<T_fp>(max_int) ? max_int : min_int;
} else {
*dst = static_cast<T_int>(std::trunc(element));
}
......@@ -5990,8 +5990,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_uint max_int = std::numeric_limits<T_uint>::max();
if (std::isnan(element)) {
*dst = 0;
} else if (element >= max_int || element <= 0) {
*dst = element >= max_int ? max_int : 0;
} else if (element >= static_cast<T_fp>(max_int) || element <= 0) {
*dst = element >= static_cast<T_fp>(max_int) ? max_int : 0;
} else {
*dst = static_cast<T_uint>(std::trunc(element));
}
......@@ -6066,8 +6066,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_int min_int = std::numeric_limits<T_int>::min();
if (std::isnan(element)) {
*dst = 0;
} else if (element < min_int || element > max_int) {
*dst = element > max_int ? max_int : min_int;
} else if (element < min_int || element > static_cast<T_fp>(max_int)) {
*dst = element > static_cast<T_fp>(max_int) ? max_int : min_int;
} else {
sim->round_according_to_msacsr<T_fp, T_int>(element, &element, dst);
}
......@@ -6078,8 +6078,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_uint max_uint = std::numeric_limits<T_uint>::max();
if (std::isnan(element)) {
*dst = 0;
} else if (element < 0 || element > max_uint) {
*dst = element > max_uint ? max_uint : 0;
} else if (element < 0 || element > static_cast<T_fp>(max_uint)) {
*dst = element > static_cast<T_fp>(max_uint) ? max_uint : 0;
} else {
T_uint res;
sim->round_according_to_msacsr<T_fp, T_uint>(element, &element, &res);
......
......@@ -1099,7 +1099,7 @@ bool Simulator::set_fcsr_round64_error(double original, double rounded) {
bool ret = false;
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
clear_fcsr_cause();
......@@ -1213,7 +1213,7 @@ void Simulator::set_fpu_register_invalid_result64(float original,
if (FCSR_ & kFCSRNaN2008FlagMask) {
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
if (std::isnan(original)) {
set_fpu_register(fd_reg(), 0);
......@@ -1272,7 +1272,7 @@ void Simulator::set_fpu_register_invalid_result64(double original,
if (FCSR_ & kFCSRNaN2008FlagMask) {
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
if (std::isnan(original)) {
set_fpu_register(fd_reg(), 0);
......@@ -1294,7 +1294,7 @@ bool Simulator::set_fcsr_round64_error(float original, float rounded) {
bool ret = false;
// The value of INT64_MAX (2^63-1) can't be represented as double exactly,
// loading the most accurate representation into max_int64, which is 2^63.
double max_int64 = std::numeric_limits<int64_t>::max();
double max_int64 = static_cast<double>(std::numeric_limits<int64_t>::max());
double min_int64 = std::numeric_limits<int64_t>::min();
clear_fcsr_cause();
......@@ -6269,8 +6269,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_int min_int = std::numeric_limits<T_int>::min();
if (std::isnan(element)) {
*dst = 0;
} else if (element >= max_int || element <= min_int) {
*dst = element >= max_int ? max_int : min_int;
} else if (element >= static_cast<T_fp>(max_int) || element <= min_int) {
*dst = element >= static_cast<T_fp>(max_int) ? max_int : min_int;
} else {
*dst = static_cast<T_int>(std::trunc(element));
}
......@@ -6281,8 +6281,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_uint max_int = std::numeric_limits<T_uint>::max();
if (std::isnan(element)) {
*dst = 0;
} else if (element >= max_int || element <= 0) {
*dst = element >= max_int ? max_int : 0;
} else if (element >= static_cast<T_fp>(max_int) || element <= 0) {
*dst = element >= static_cast<T_fp>(max_int) ? max_int : 0;
} else {
*dst = static_cast<T_uint>(std::trunc(element));
}
......@@ -6357,8 +6357,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_int min_int = std::numeric_limits<T_int>::min();
if (std::isnan(element)) {
*dst = 0;
} else if (element < min_int || element > max_int) {
*dst = element > max_int ? max_int : min_int;
} else if (element < min_int || element > static_cast<T_fp>(max_int)) {
*dst = element > static_cast<T_fp>(max_int) ? max_int : min_int;
} else {
sim->round_according_to_msacsr<T_fp, T_int>(element, &element, dst);
}
......@@ -6369,8 +6369,8 @@ T_int Msa2RFInstrHelper(uint32_t opcode, T_src src, T_dst* dst,
const T_uint max_uint = std::numeric_limits<T_uint>::max();
if (std::isnan(element)) {
*dst = 0;
} else if (element < 0 || element > max_uint) {
*dst = element > max_uint ? max_uint : 0;
} else if (element < 0 || element > static_cast<T_fp>(max_uint)) {
*dst = element > static_cast<T_fp>(max_uint) ? max_uint : 0;
} else {
T_uint res;
sim->round_according_to_msacsr<T_fp, T_uint>(element, &element, &res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment