From patchwork Thu Feb 1 20:41:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 868425 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89893-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="tx0KWii8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zXX8r5msQz9sBZ for ; Fri, 2 Feb 2018 07:41:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=nm76tl4nNneHd2qXoNUJhJTUj7Cmj tqETusxYkSphV8nxIUmB1bJL7CG/YYsrncZ0/QElh3Hlhd1L5wtMXvMcQM08snyl beQZN/4BeXqiYk1CGPNsl4VhdXvfBhQtOY1B1oOoN9vULwsBFn7ZyczvuZRYhmbc KOs2xr3arixsIo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=xEExyWs/SCSdDRp2ODd/sEXnv4s=; b=tx0 KWii84EIkF8FN7um1XGWlpN0KGKuWyGMUjPZYPETnW+AaHmJEZB/uWDjVaPD+FNS Tz48PmxkInzk9in3J50LnuIAJrhFcs1CHrWAdQ7t8Vb9gLySkMlNLXkSslFFCLX0 UaRQxvnDqGiHIBJwDiU4SmsgCqF8TW9XbVPMda9U= Received: (qmail 125495 invoked by alias); 1 Feb 2018 20:41:43 -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 125476 invoked by uid 89); 1 Feb 2018 20:41:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 1 Feb 2018 20:41:35 +0000 From: Joseph Myers To: Subject: Fix -Os log1p, log1pf build (bug 21314) [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) As reported in bug 21314, building log1p and log1pf fails with -Os because of a spurious -Wmaybe-uninitialized warning (reported there for GCC 5 for MIPS, I see it also with GCC 7 for x86_64). This patch, based on the patches in the bug, fixes this using the DIAG_* macros. Tested for x86_64 with -Os that this eliminates those warnings and so allows the build to progress further. Committed. 2018-02-01 Carlos O'Donell Ramin Seyed-Moussavi Joseph Myers [BZ #21314] * sysdeps/ieee754/dbl-64/s_log1p.c: Include . (__log1p): Disable -Wmaybe-uninitialized for -Os around computation using c. * sysdeps/ieee754/flt-32/s_log1pf.c: Include . (__log1pf): Disable -Wmaybe-uninitialized for -Os around computation using c. diff --git a/sysdeps/ieee754/dbl-64/s_log1p.c b/sysdeps/ieee754/dbl-64/s_log1p.c index 340f637..b7cf5ce 100644 --- a/sysdeps/ieee754/dbl-64/s_log1p.c +++ b/sysdeps/ieee754/dbl-64/s_log1p.c @@ -81,6 +81,7 @@ #include #include #include +#include static const double ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ @@ -191,5 +192,14 @@ __log1p (double x) if (k == 0) return f - (hfsq - s * (hfsq + R)); else - return k * ln2_hi - ((hfsq - (s * (hfsq + R) + (k * ln2_lo + c))) - f); + { + /* With GCC 7 when compiling with -Os the compiler warns that c + might be used uninitialized. This can't be true because k + must be 0 for c to be uninitialized and we handled that + computation earlier without using c. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); + return k * ln2_hi - ((hfsq - (s * (hfsq + R) + (k * ln2_lo + c))) - f); + DIAG_POP_NEEDS_COMMENT; + } } diff --git a/sysdeps/ieee754/flt-32/s_log1pf.c b/sysdeps/ieee754/flt-32/s_log1pf.c index ade60a2..009084e 100644 --- a/sysdeps/ieee754/flt-32/s_log1pf.c +++ b/sysdeps/ieee754/flt-32/s_log1pf.c @@ -16,6 +16,7 @@ #include #include #include +#include static const float ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ @@ -97,6 +98,18 @@ __log1pf(float x) s = f/((float)2.0+f); z = s*s; R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7)))))); - if(k==0) return f-(hfsq-s*(hfsq+R)); else - return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f); + if (k == 0) + return f - (hfsq - s * (hfsq + R)); + else + { + /* With GCC 7 when compiling with -Os the compiler warns + that c might be used uninitialized. This can't be true + because k must be 0 for c to be uninitialized and we + handled that computation earlier without using c. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized"); + return k * ln2_hi - ((hfsq - (s * (hfsq + R) + + (k * ln2_lo + c))) - f); + DIAG_POP_NEEDS_COMMENT; + } }