From patchwork Mon Oct 9 08:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 77278 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 065EC3858004 for ; Mon, 9 Oct 2023 08:17:23 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id AEB503858D1E for ; Mon, 9 Oct 2023 08:17:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEB503858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B8FEC21879 for ; Mon, 9 Oct 2023 08:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696839429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=nuwnEzC8Wly7mGrCQsSo5dzq0U/vx6Gq2ftbs6LShVs=; b=sl1yVqbx8q1+g1fWoIhqPO4U//aAfsDOXotPRIVmKC5k2OqwBRhuP0ZrOQ2kruUVFiClcT kDBP8uWfAHPdx0lrHUNOtkpRdlgBg707ez+2AJUKg1E8GeqWdoX12aGdFRbUIInrkOUHBd zDK7B8XZSL42/dHcMGXcR7fTta4oRB8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696839429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=nuwnEzC8Wly7mGrCQsSo5dzq0U/vx6Gq2ftbs6LShVs=; b=97XU+FUT/r4M5yq8ed22nNN8rJMhEHIeoC/12ruq91ECvKLTIUn9MF4FS50KHLX56fCHrX N26HUUtwrGGsKtBg== Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 8E6652C142 for ; Mon, 9 Oct 2023 08:17:09 +0000 (UTC) Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id A85D64A051C; Mon, 9 Oct 2023 10:17:09 +0200 (CEST) From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Avoid maybe-uninitialized warning in __kernel_rem_pio2 X-Yow: Did we bring enough BEEF JERKY? Date: Mon, 09 Oct 2023 10:17:09 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org With GCC 14 on 32-bit x86 the compiler emits a maybe-uninitialized warning: ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function '__kernel_rem_pio2': ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:364:20: error: 'fq' may be used uninitialized [-Werror=maybe-uninitialized] 364 | y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; | ~~^~~ This is similar to the warning that is suppressed in the other branch of the switch. Help the compiler knowing that the variable is always initialized, which also makes the suppression obsolete. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/dbl-64/k_rem_pio2.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c index 6e2ef5d07b..af29685c68 100644 --- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c +++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c @@ -300,6 +300,11 @@ recompute: iq[jz] = (int32_t) z; } + /* jz is always nonnegative here, because the result is never zero to + full precision (this function is not called for zero arguments). Help + the compiler to know it. */ + if (jz < 0) __builtin_unreachable (); + /* convert integer "bit" chunk to floating-point value */ fw = __scalbn (one, q0); for (i = jz; i >= 0; i--) @@ -330,16 +335,7 @@ recompute: for (i = jz; i >= 0; i--) fv = math_narrow_eval (fv + fq[i]); y[0] = (ih == 0) ? fv : -fv; - /* GCC mainline (to be GCC 9), as of 2018-05-22 on i686, warns - that fq[0] may be used uninitialized. This is not possible - because jz is always nonnegative when the above loop - initializing fq is executed, because the result is never zero - to full precision (this function is not called for zero - arguments). */ - DIAG_PUSH_NEEDS_COMMENT; - DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized"); fv = math_narrow_eval (fq[0] - fv); - DIAG_POP_NEEDS_COMMENT; for (i = 1; i <= jz; i++) fv = math_narrow_eval (fv + fq[i]); y[1] = (ih == 0) ? fv : -fv;