target-tricore: split up suov32 into suov32_pos and suov32_neg
commit85d604af5f96c32734af9974ec6ddb625b6716a2
authorBastian Koppelmann <kbastian@mail.uni-paderborn.de>
Mon, 19 Jan 2015 14:28:59 +0000 (19 14:28 +0000)
committerBastian Koppelmann <kbastian@mail.uni-paderborn.de>
Mon, 26 Jan 2015 19:56:46 +0000 (26 19:56 +0000)
tree63b12215c9d770e7129ede77387c56caf5931972
parent40a1f64b468ee247fca3b237f0b89f066e59626c
target-tricore: split up suov32 into suov32_pos and suov32_neg

suov checks unsigned for an overflow and an underflow, after some arithmetic
operations and saturates the result to either max_uint32 or 0. So far we
handled this by expanding to the next bigger data type and compare whether
the result is > max_uint32 or < 0.

However this approach can fail for an 32 bit multiplication, if both operands of
the multiplication are 0x80000000. This sets the sign bit of the 64 bit integer
and would result in a false saturation to 0.

Since unsigned operations, e.g add, sub, mul always result in either a positive
or negative overflow, we split the functions for suov32 up into two functions
(suov32_pos, suov32_neg) for each case.

Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
target-tricore/op_helper.c