diff options
Diffstat (limited to 'clang/lib/Basic/FixedPoint.cpp')
-rw-r--r-- | clang/lib/Basic/FixedPoint.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Basic/FixedPoint.cpp b/clang/lib/Basic/FixedPoint.cpp index 58037ff3983..bfff0fc212e 100644 --- a/clang/lib/Basic/FixedPoint.cpp +++ b/clang/lib/Basic/FixedPoint.cpp @@ -59,7 +59,8 @@ int APFixedPoint::compare(const APFixedPoint &Other) const { unsigned CommonWidth = std::max(Val.getBitWidth(), OtherWidth); // Prevent overflow in the event the widths are the same but the scales differ - CommonWidth += std::abs(static_cast<int>(getScale() - OtherScale)); + CommonWidth += getScale() >= OtherScale ? getScale() - OtherScale + : OtherScale - getScale(); ThisVal = ThisVal.extOrTrunc(CommonWidth); OtherVal = OtherVal.extOrTrunc(CommonWidth); |