Index: src/s390/simulator-s390.cc |
diff --git a/src/s390/simulator-s390.cc b/src/s390/simulator-s390.cc |
index d387812bd7164097a9a57ad4669171967f60dab2..b669dcb20701c8bebd1fe3e7dfd5cda3574aa094 100644 |
--- a/src/s390/simulator-s390.cc |
+++ b/src/s390/simulator-s390.cc |
@@ -6265,10 +6265,21 @@ EVALUATE(CLFEBR) { |
EVALUATE(CLFDBR) { |
DCHECK_OPCODE(CLFDBR); |
DECODE_RRE_INSTRUCTION(r1, r2); |
- double r2_val = get_double_from_d_register(r2); |
- uint32_t r1_val = static_cast<uint32_t>(r2_val); |
+ double a = get_double_from_d_register(r2); |
+ double n = std::round(a); |
+ uint32_t r1_val = static_cast<uint32_t>(n); |
set_low_register(r1, r1_val); |
- SetS390ConvertConditionCode<double>(r2_val, r1_val, UINT32_MAX); |
+ if (std::isfinite(a) && a < 0.0) { |
+ DCHECK(n <= 0.0 && std::isfinite(n)); |
+ condition_reg_ = (n < 0.0) ? 0x1 : 0x4; |
+ } else if (a == 0.0) { |
+ condition_reg_ = 0x8; |
+ } else if (std::isfinite(a) && a > 0.0) { |
+ DCHECK(n >= 0.0 && std::isfinite(n)); |
+ condition_reg_ = (n <= static_cast<double>(UINT32_MAX)) ? 0x2 : 0x1; |
+ } else { |
+ condition_reg_ = 0x1; |
+ } |
return length; |
} |