Commit 0d24a0fc authored by bryleun's avatar bryleun Committed by Commit bot

S390: Fixed s390 simulation check for underflow in subtraction.

Clang optimizes away CheckOverflowForIntSub at any opt
level (includes -O1, -O2, -O3) into a false statement,
resulting in incorrect values being returned. As the C++
standard considers overflows to be undefined behaviour,
this is technically correct as compilers can assume that
overflows never occur, but problematic in our case (where
overflows do occur, and a specific result is expected).

This change replaces the original check with a call to a
function that is optimized in a manner that returns correct output.

R=michael_dawson@ca.ibm.com,jyan@ca.ibm.com,mtbrandyberry@ca.ibm.com,joransiu@ca.ibm.com,danno@chromium.org,jkummerow@chromium.org,jochen@chromium.org

BUG=

Review URL: https://codereview.chromium.org/1826043002

Cr-Commit-Position: refs/heads/master@{#35082}
parent f5b85cb7
This diff is collapsed.
......@@ -258,8 +258,8 @@ class Simulator {
// Helper functions to set the conditional flags in the architecture state.
bool CarryFrom(int32_t left, int32_t right, int32_t carry = 0);
bool BorrowFrom(int32_t left, int32_t right);
bool OverflowFrom(int32_t alu_out, int32_t left, int32_t right,
bool addition);
template <typename T1>
inline bool OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition);
// Helper functions to decode common "addressing" modes
int32_t GetShiftRm(Instruction* instr, bool* carry_out);
......
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