From patchwork Tue Dec 21 16:59:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 49156 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 9F68B3858017 for ; Tue, 21 Dec 2021 17:00:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F68B3858017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640106022; bh=NX7fwLxdijvvdfIyRVCfGyqjqKgvRaRLFo08JdRAEAk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uxjFqom/W9dFuQe+gqxKlscBy2h0ydCE0yGSNba6JQVVGNkA7NLGV7R5c9dbUlXw/ IkoeexjdLpoJh0kzJ8UYmZWHCWiRqkpCIyw9A1xIZv703mQUHeXFYWPAmjcFBONXTv q5+v/Ii87Va59e9WVHyjhnqtCwBGaPhuAlds8K7I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 6E3063858C3A for ; Tue, 21 Dec 2021 17:00:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E3063858C3A Received: by mail-pj1-x1036.google.com with SMTP id jw3so9633667pjb.4 for ; Tue, 21 Dec 2021 09:00:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=NX7fwLxdijvvdfIyRVCfGyqjqKgvRaRLFo08JdRAEAk=; b=Z5whpmKeW7n8WEP19vJ5VNCEIdSemX4pU2imjwXOUsQlqehPjcBRFREyDx++C8NCJL MH51V1TY98zSSL1UQZJdMqR9RtNJ+Yq22V4bXAcOnAfdun0669xjmjYl4gVkDXUPRVIU F0YNDurIGkI2mfMfqVGRNx8da1trU0DjHi6/Y25WXEVrEANOUR4zTge3piyXYBbm6uUV 8jinV9dCGsvuqOp2glC2Y+VPTsrHprV5cU8HEoH1bScJ5F+zvDZE1+AepR0D7JUrFPvT wBqKJC2E2QPQ94YjiTsP06IMr9uXTZ5P0w2YmqO1c5xXb2x+S0i89txZN9apIXXelaZc DYZA== X-Gm-Message-State: AOAM533C8ApbbpvMoLptt1w2QOXESUJAtOf8FIntfOqOx4tbM/f67VrI lGRK2LPNHWsd+b1QWNqfcEd9T548fp8= X-Google-Smtp-Source: ABdhPJxN/7jufnyGRqiBe+RE49Ze4fxFiR8SMWssYXEpACAzqp+fgfMs2N0DGuZnkZ4whGioK1wlrA== X-Received: by 2002:a17:902:e88c:b0:148:e74a:5fbc with SMTP id w12-20020a170902e88c00b00148e74a5fbcmr4195510plg.168.1640106000223; Tue, 21 Dec 2021 09:00:00 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id v63sm20141100pgv.71.2021.12.21.08.59.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:59:59 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id A1EB7C042C for ; Tue, 21 Dec 2021 08:59:58 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2] math: Properly cast X_TLOSS to float [BZ #28713] Date: Tue, 21 Dec 2021 08:59:58 -0800 Message-Id: <20211221165958.1236739-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3029.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Add #define AS_FLOAT_CONSTANT_1(x) x##f #define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x) to cast X_TLOSS to float at compile-time to fix: FAIL: math/test-float-j0 FAIL: math/test-float-jn FAIL: math/test-float-y0 FAIL: math/test-float-y1 FAIL: math/test-float-yn FAIL: math/test-float32-j0 FAIL: math/test-float32-jn FAIL: math/test-float32-y0 FAIL: math/test-float32-y1 FAIL: math/test-float32-yn when compiling with GCC 12. --- math/math-svid-compat.h | 2 ++ math/w_j0f_compat.c | 5 +++-- math/w_j1f_compat.c | 5 +++-- math/w_jnf_compat.c | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/math/math-svid-compat.h b/math/math-svid-compat.h index 5c18cb1b03..876cadde40 100644 --- a/math/math-svid-compat.h +++ b/math/math-svid-compat.h @@ -49,6 +49,8 @@ extern int matherr (struct exception *__exc); extern int __matherr (struct exception *__exc); #define X_TLOSS 1.41484755040568800000e+16 +#define AS_FLOAT_CONSTANT_1(x) x##f +#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x) /* Types of exceptions in the `type' field. */ #define DOMAIN 1 diff --git a/math/w_j0f_compat.c b/math/w_j0f_compat.c index d375f3bfb0..3257533596 100644 --- a/math/w_j0f_compat.c +++ b/math/w_j0f_compat.c @@ -27,7 +27,8 @@ float __j0f (float x) { - if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0) + if (__builtin_expect (isgreater (fabsf (x), + AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_) /* j0(|x|>X_TLOSS) */ return __kernel_standard_f (x, x, 134); @@ -42,7 +43,7 @@ float __y0f (float x) { if (__builtin_expect (islessequal (x, 0.0f) - || isgreater (x, (float) X_TLOSS), 0) + || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0f) diff --git a/math/w_j1f_compat.c b/math/w_j1f_compat.c index 81e56b771e..025ed3ab46 100644 --- a/math/w_j1f_compat.c +++ b/math/w_j1f_compat.c @@ -27,7 +27,8 @@ float __j1f (float x) { - if (__builtin_expect (isgreater (fabsf (x), X_TLOSS), 0) + if (__builtin_expect (isgreater (fabsf (x), + AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_) /* j1(|x|>X_TLOSS) */ return __kernel_standard_f (x, x, 136); @@ -42,7 +43,7 @@ float __y1f (float x) { if (__builtin_expect (islessequal (x, 0.0f) - || isgreater (x, (float) X_TLOSS), 0) + || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0f) diff --git a/math/w_jnf_compat.c b/math/w_jnf_compat.c index 296e631566..ee9e80c494 100644 --- a/math/w_jnf_compat.c +++ b/math/w_jnf_compat.c @@ -27,7 +27,8 @@ float __jnf (int n, float x) { - if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0) + if (__builtin_expect (isgreater (fabsf (x), + AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_) /* jn(n,|x|>X_TLOSS) */ return __kernel_standard_f (n, x, 138); @@ -42,7 +43,7 @@ float __ynf (int n, float x) { if (__builtin_expect (islessequal (x, 0.0f) - || isgreater (x, (float) X_TLOSS), 0) + || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0f)