From patchwork Tue Aug 16 17:12:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 14621 Received: (qmail 106221 invoked by alias); 16 Aug 2016 17:12:44 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 106198 invoked by uid 89); 16 Aug 2016 17:12:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=tfmode, TFmode, _f1, 3487 X-HELO: relay1.mentorg.com Date: Tue, 16 Aug 2016 17:12:36 +0000 From: Joseph Myers To: Subject: Fix soft-fp extended.h unpacking (GCC bug 77265) [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 soft-fp unpacking for x86 "extended" fails to clear the implicit mantissa high bit that is explicit in that format, resulting in problems for operations that expect this bit to be clear in raw unpacked values. Specifically, the code for this format is used only for conversions to and from TFmode (__float128) in libgcc, where this issue results in GCC bug 77265, extension of long double infinity to __float128 wrongly produces a NaN. This patch fixes this by always masking out the implicit bit on unpacking, so that the results of unpacking meet the expectations of the rest of the soft-fp code for a normal IEEE format. Tested for x86_64 in libgcc in conjunction with a GCC testcase for this issue (this code isn't used in glibc, only in libgcc). Committed. 2016-08-16 Joseph Myers * soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_E): Mask implicit bit out of unpacked value. [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_EP): Likewise. [_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_E): Likewise. [_FP_W_TYPE_SIZE >= 64] (FP_UNPACK_RAW_EP): Likewise. diff --git a/soft-fp/extended.h b/soft-fp/extended.h index de53448..7b19e83 100644 --- a/soft-fp/extended.h +++ b/soft-fp/extended.h @@ -104,6 +104,7 @@ union _FP_UNION_E X##_f[3] = 0; \ X##_f[0] = FP_UNPACK_RAW_E_flo.bits.frac0; \ X##_f[1] = FP_UNPACK_RAW_E_flo.bits.frac1; \ + X##_f[1] &= ~_FP_IMPLBIT_E; \ X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \ X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \ } \ @@ -119,6 +120,7 @@ union _FP_UNION_E X##_f[3] = 0; \ X##_f[0] = FP_UNPACK_RAW_EP_flo->bits.frac0; \ X##_f[1] = FP_UNPACK_RAW_EP_flo->bits.frac1; \ + X##_f[1] &= ~_FP_IMPLBIT_E; \ X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \ X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \ } \ @@ -332,6 +334,7 @@ union _FP_UNION_E FP_UNPACK_RAW_E_flo.flt = (val); \ \ X##_f0 = FP_UNPACK_RAW_E_flo.bits.frac; \ + X##_f0 &= ~_FP_IMPLBIT_E; \ X##_f1 = 0; \ X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \ X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \ @@ -345,6 +348,7 @@ union _FP_UNION_E = (union _FP_UNION_E *) (val); \ \ X##_f0 = FP_UNPACK_RAW_EP_flo->bits.frac; \ + X##_f0 &= ~_FP_IMPLBIT_E; \ X##_f1 = 0; \ X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \ X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \