HomePhabricator

Fix incorrect truncation at the overflow boundary

Description

Fix incorrect truncation at the overflow boundary

Summary:
This patch fixes incorrect truncation when the input wider value is
exactly 2^dstBits. For that value, the overflow to infinity is not
correctly handled. The fix is to replace a strict '>' with '>='.

Currently,
truncdfsf2(340282366900000000000000000000000000000.0) returns infinity
truncdfsf2(340282366920938463463374607431768211456.0) returns 0
__truncdfsf2(400000000000000000000000000000000000000.0) returns infinity

Likewise, truncdfhf2 and truncsfhf2 (and consequently gnu_f2h_ieee)
are discontinuous at 65536.0.

This patch adds tests for all three cases, along with adding a missing
header include to fp_test.h.

Reviewers: joerg, ab, srhines

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10594

Details

Committed
piramaJun 23 2015, 1:24 PM
Differential Revision
D10594: Fix incorrect truncation at the overflow boundary
Parents
rCRT240449: [msan] Mark one test as only supported on x86
Branches
Unknown
Tags
Unknown