summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Basic/FixedPointTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Basic/FixedPointTest.cpp')
-rw-r--r--clang/unittests/Basic/FixedPointTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/unittests/Basic/FixedPointTest.cpp b/clang/unittests/Basic/FixedPointTest.cpp
index 6d608f1faff..74b676bb21f 100644
--- a/clang/unittests/Basic/FixedPointTest.cpp
+++ b/clang/unittests/Basic/FixedPointTest.cpp
@@ -364,12 +364,19 @@ TEST(FixedPoint, compare) {
void CheckUnsaturatedConversion(FixedPointSemantics Src,
FixedPointSemantics Dst, int64_t TestVal) {
int64_t ScaledVal = TestVal;
+ bool IsNegative = ScaledVal < 0;
+ if (IsNegative)
+ ScaledVal = -ScaledVal;
+
if (Dst.getScale() > Src.getScale()) {
ScaledVal <<= (Dst.getScale() - Src.getScale());
} else {
ScaledVal >>= (Src.getScale() - Dst.getScale());
}
+ if (IsNegative)
+ ScaledVal = -ScaledVal;
+
APFixedPoint Fixed(TestVal, Src);
APFixedPoint Expected(ScaledVal, Dst);
ASSERT_EQ(Fixed.convert(Dst), Expected);
OpenPOWER on IntegriCloud