From patchwork Thu Dec 28 17:20:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SXIQh2Uo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1FfP71YTz23d7 for ; Fri, 29 Dec 2023 04:21:17 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 008B838582BB for ; Thu, 28 Dec 2023 17:21:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 5BE973858C33 for ; Thu, 28 Dec 2023 17:20:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BE973858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5BE973858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784038; cv=none; b=oh/2sAuv2BDrcHaQoSdjzgj7rvFaz9m9is0vwOe8EhanNaJrarEenOSeWPwLdfighTPM7SMc/ZCHqjAyFxEgSkNMv9gcfCvzqtdgQbCafrsffJ4nixDPOd/a78AOREX273TjdRIWWjDIGaqddQyMZhK1axx9DmawB+7qn286u2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784038; c=relaxed/simple; bh=f6MCGGB7zrDe8wdKBZMhj1wcv4XtJ4IUloERqQsECqM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=sPjX1GyftKVDw7rVCa0JYl1WsJo6Nh3Sy0b7zuGcfV7bn1bAYUMn+GpDDcDFB4dtqObfcgxysYyGgIX1HFOotvAMKgUu53G8TSZSuD24gvccQEVWlHgqUif6isHTD6SqS6RVFGNDkkSWczAL0eoQGDEZ2Z1yYzxLojUAerFD4Hc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6dc1fdc19b6so326593a34.0 for ; Thu, 28 Dec 2023 09:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784032; x=1704388832; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m5Bjf8y1Be9hhOdfnd0D5Fk5Skb5ohpdAFSHnEcAXEE=; b=SXIQh2Uo35HR3DFRdJWMD3IaGiklujFacMy1fW7/dVCDpfHrHyIVYsjcgqxCZWI5I8 vc9D0huz+v1ROQjqOK4aWEdjqCgUCLMQP0Iy1QUJGQ4uUASIMCWnj9CZlkzlF6cLU6xL m11991iW9WgDSVRq6WzCNqB6W9g5rAdvW8rbWgId7tanReQbbLErKaQInnrhQrNie5ku 4wPhCNX/XaxVCeTlgbKBAicp7qoncR4PsaFpiw9IRuz9FW87qUxbs2bIHX4AZuUT7OfF UpWjsMb+h3Vq3TX346AUSiN7bgKPW1HcIAVtXC7u5bOoUA7WTujHYWyt8lPkpdVGARPV s4NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784032; x=1704388832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5Bjf8y1Be9hhOdfnd0D5Fk5Skb5ohpdAFSHnEcAXEE=; b=rEi0Pq78I8swv+vkK2hUWTG7DOJskpF0ObDvGx6OZP69UhBdk6dsavFc6N3hasqYzL MMl+ehdI/30pnYidM6wz+urk540Prw8lcHzUNzRd0dvui4JZqiyC0L38jIYzTR9Nqbex 27k+yoJ/6N+VvjjebCXuSGq6WeeJsjJRi2RxLZhIFSQi3uyUsGcATHA8IY3E/9/EzmaZ gdJr7iWrxOXySQVAWaiZIDI/E/HG6r+akq5YSUW8hSDzTZYQCkI6qFK4/83FZ8k7CFT4 ka21MUP6zUOXLAn8eLeNkFkxFqjkOBTEvRXRbSUpQCDoE16KNhFo2OLCYv1jS2jPOMXe w6sQ== X-Gm-Message-State: AOJu0YydAIoHo5aBT4ocKjO30HT7yYm1rvA2VnNsXInYVOJanT3ahwDb A970fBo10Xujwvc/18u3iwwXCNSaLtIZDr6CIjsWkvAZznE= X-Google-Smtp-Source: AGHT+IFtggOnLOjnykjYQgQ8kyFzRvp4C+1Xl8nzyilfWErHuP/+If36GE3KVBWAiCP9dCMMWQEo+w== X-Received: by 2002:a9d:4d99:0:b0:6db:c4cd:4a1 with SMTP id u25-20020a9d4d99000000b006dbc4cd04a1mr8755584otk.41.1703784031699; Thu, 28 Dec 2023 09:20:31 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:30 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 01/12] math: Reformat Makefile. Date: Thu, 28 Dec 2023 14:20:15 -0300 Message-Id: <20231228172026.2013007-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKTIP, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org Reflow all long lines adding comment terminators. Sort all reflowed text using scripts/sort-makefile-lines.py. No code generation changes observed in binary artifacts. No regressions on x86_64 and i686. Reviewed-by: H.J. Lu --- math/Makefile | 844 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 685 insertions(+), 159 deletions(-) diff --git a/math/Makefile b/math/Makefile index a9daae09de..5a912c55bd 100644 --- a/math/Makefile +++ b/math/Makefile @@ -22,87 +22,279 @@ subdir := math include ../Makeconfig # Installed header files. -headers := math.h bits/mathcalls.h \ - fpu_control.h complex.h bits/cmathcalls.h fenv.h \ - bits/fenv.h bits/mathdef.h tgmath.h \ - bits/math-vector.h finclude/math-vector-fortran.h \ - bits/libm-simd-decl-stubs.h bits/iscanonical.h \ - bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \ - bits/long-double.h bits/mathcalls-helper-functions.h \ - bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h +headers := \ + math.h \ + bits/mathcalls.h \ + fpu_control.h \ + complex.h \ + bits/cmathcalls.h \ + fenv.h \ + bits/fenv.h \ + bits/mathdef.h \ + tgmath.h \ + bits/math-vector.h \ + finclude/math-vector-fortran.h \ + bits/libm-simd-decl-stubs.h \ + bits/iscanonical.h \ + bits/flt-eval-method.h \ + bits/fp-fast.h \ + bits/fp-logb.h \ + bits/long-double.h \ + bits/mathcalls-helper-functions.h \ + bits/floatn.h \ + bits/floatn-common.h \ + bits/mathcalls-narrow.h + # headers # FPU support code. -aux := setfpucw fpu_control +aux := \ + fpu_control \ + setfpucw \ + # aux # Build the -lm library. extra-libs := libm extra-libs-others = $(extra-libs) -libm-support = s_lib_version s_matherr s_signgam \ - fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \ - ftestexcept fegetround fesetround fegetenv feholdexcpt \ - fesetenv feupdateenv fedisblxcpt feenablxcpt \ - fegetexcept fesetexcept fetestexceptflag fegetmode \ - fesetmode +libm-support = \ + fclrexcpt \ + fedisblxcpt \ + feenablxcpt \ + fegetenv \ + fegetexcept \ + fegetmode \ + fegetround \ + feholdexcpt \ + fesetenv \ + fesetexcept \ + fesetmode\ + fesetround \ + fetestexceptflag \ + feupdateenv \ + fgetexcptflg \ + fraiseexcpt \ + fsetexcptflg \ + ftestexcept \ + s_lib_version \ + s_matherr \ + s_signgam \ + # libm-support # Wrappers for these functions generated per type using a file named # _template.c and the appropriate math-type-macros-.h. -gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF \ - s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \ - k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \ - s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \ - s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF \ - s_nanF s_iseqsigF s_canonicalizeF s_significandF \ - w_ilogbF w_llogbF \ - w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF \ - w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F \ - w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF \ - w_log10F w_log2F w_powF w_remainderF w_scalbF \ - w_sinhF w_sqrtF \ - w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F \ - s_fmaximumF s_fmaximum_magF s_fmaximum_numF \ - s_fmaximum_mag_numF s_fminimumF s_fminimum_magF \ - s_fminimum_numF s_fminimum_mag_numF - -libm-calls = \ - e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \ - e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \ - e_remainderF e_sinhF e_sqrtF e_gammaF_r \ - e_ilogbF \ - k_tanF s_asinhF s_atanF s_cbrtF \ - s_ceilF s_cosF s_erfF s_expm1F s_fabsF \ - s_floorF s_log1pF s_logbF \ - s_nextafterF s_nexttowardF s_rintF s_scalblnF \ - s_sinF s_tanF s_tanhF \ - s_fpclassifyF s_truncF \ - s_remquoF e_log2F s_roundF s_nearbyintF s_sincosF \ - s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F \ - s_issignalingF $(calls:s_%=m_%) x2y2m1F \ - gamma_productF lgamma_negF lgamma_productF \ - s_nextupF s_totalorderF s_totalordermagF s_getpayloadF \ - s_setpayloadF s_setpayloadsigF s_roundevenF s_fromfpF s_ufromfpF \ - s_fromfpxF s_ufromfpxF $(gen-libm-calls) - -libm-compat-calls = \ - w_acosF_compat w_acoshF_compat w_asinF_compat w_atan2F_compat \ - w_atanhF_compat w_coshF_compat w_exp2F_compat w_exp10F_compat \ - w_fmodF_compat w_hypotF_compat w_j0F_compat w_j1F_compat \ - w_jnF_compat w_log2F_compat w_log10F_compat w_logF_compat \ - w_powF_compat w_remainderF_compat w_scalbF_compat \ - w_sinhF_compat w_sqrtF_compat w_tgammaF_compat \ - w_lgammaF_r_compat w_lgammaF_compat2 w_expF_compat \ - w_lgamma_compatF k_standardF - -libm-narrow-fns = add div fma mul sqrt sub -libm-narrow-types-basic = s_fF s_f32xFf64 -libm-narrow-types-ldouble-yes = s_fFl s_dFl -libm-narrow-types-float128-yes = s_f32Ff128 s_f64Ff128 s_f64xFf128 -libm-narrow-types-float128-alias-yes = s_f64xFf128 -libm-narrow-types = $(libm-narrow-types-basic) \ - $(libm-narrow-types-ldouble-$(long-double-fcts)) \ - $(libm-narrow-types-float128-$(float128-fcts)) \ - $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) +gen-libm-calls = \ + cabsF \ + cargF \ + cimagF \ + conjF \ + crealF \ + e_exp2F \ + e_scalbF \ + k_casinhF \ + k_casinhF \ + s_cacosF \ + s_cacoshF \ + s_canonicalizeF \ + s_casinF \ + s_casinhF \ + s_catanF \ + s_catanhF \ + s_ccosF \ + s_ccoshF \ + s_cexpF \ + s_clog10F \ + s_clogF \ + s_cpowF \ + s_cprojF \ + s_csinF \ + s_csinhF \ + s_csinhF \ + s_csqrtF \ + s_ctanF \ + s_ctanhF \ + s_fdimF \ + s_fmaxF \ + s_fmaximumF \ + s_fmaximum_magF \ + s_fmaximum_mag_numF \ + s_fmaximum_numF \ + s_fmaxmagF \ + s_fminF \ + s_fminimumF \ + s_fminimum_magF \ + s_fminimum_mag_numF \ + s_fminimum_numF \ + s_fminmagF \ + s_iseqsigF \ + s_nanF \ + s_nextdownF \ + s_significandF \ + w_acosF \ + w_acoshF \ + w_asinF \ + w_atan2F \ + w_atanhF \ + w_coshF \ + w_exp10F \ + w_exp2F \ + w_expF \ + w_fmodF \ + w_hypotF \ + w_ilogbF \ + w_j0F \ + w_j1F \ + w_jnF \ + w_lgammaF \ + w_lgammaF_r \ + w_llogbF \ + w_log10F \ + w_log1pF \ + w_log2F \ + w_logF \ + w_powF \ + w_remainderF \ + w_scalbF \ + w_scalblnF \ + w_sinhF \ + w_sqrtF \ + w_tgammaF \ + # gen-libm-calls + +libm-calls = \ + $(calls:s_%=m_%) \ + $(gen-libm-calls) \ + e_acosF \ + e_acoshF \ + e_asinF \ + e_atan2F \ + e_atanhF \ + e_coshF \ + e_exp10F \ + e_expF \ + e_fmodF \ + e_gammaF_r \ + e_hypotF \ + e_ilogbF \ + e_j0F \ + e_j1F \ + e_jnF \ + e_lgammaF_r \ + e_log10F \ + e_log2F \ + e_logF \ + e_powF \ + e_remainderF \ + e_sinhF \ + e_sqrtF \ + gamma_productF \ + k_tanF \ + lgamma_negF \ + lgamma_productF \ + s_asinhF \ + s_atanF \ + s_cbrtF \ + s_ceilF \ + s_cosF \ + s_erfF \ + s_expm1F \ + s_fabsF \ + s_floorF \ + s_fmaF \ + s_fpclassifyF \ + s_fromfpF \ + s_fromfpxF \ + s_getpayloadF \ + s_issignalingF \ + s_llrintF \ + s_llroundF \ + s_log1pF \ + s_logbF \ + s_lrintF \ + s_lroundF \ + s_nearbyintF \ + s_nextafterF \ + s_nexttowardF \ + s_nextupF \ + s_remquoF \ + s_rintF \ + s_roundF \ + s_roundevenF \ + s_scalblnF \ + s_setpayloadF \ + s_setpayloadsigF \ + s_sinF \ + s_sincosF \ + s_tanF \ + s_tanhF \ + s_totalorderF \ + s_totalordermagF \ + s_truncF \ + s_ufromfpF \ + s_ufromfpxF \ + x2y2m1F \ + # libm-calls + +libm-compat-calls = \ + k_standardF \ + w_acosF_compat \ + w_acoshF_compat \ + w_asinF_compat \ + w_atan2F_compat \ + w_atanhF_compat \ + w_coshF_compat \ + w_exp10F_compat \ + w_exp2F_compat \ + w_expF_compat \ + w_fmodF_compat \ + w_hypotF_compat \ + w_j0F_compat \ + w_j1F_compat\ + w_jnF_compat \ + w_lgammaF_compat2 \ + w_lgammaF_r_compat \ + w_lgamma_compatF \ + w_log10F_compat \ + w_log2F_compat \ + w_logF_compat \ + w_powF_compat \ + w_remainderF_compat \ + w_scalbF_compat \ + w_sinhF_compat \ + w_sqrtF_compat \ + w_tgammaF_compat \ + # libm-compat-calls + +libm-narrow-fns = \ + add \ + div \ + fma \ + mul \ + sqrt \ + sub \ + # libm-narrow-fns +libm-narrow-types-basic = \ + s_f32xFf64 \ + s_fF \ + # libm-narrow-types-basic +libm-narrow-types-ldouble-yes = \ + s_dFl \ + s_fFl \ + # libm-narrow-types-ldouble-yes +libm-narrow-types-float128-yes = \ + s_f32Ff128 \ + s_f64Ff128 \ + s_f64xFf128 \ + # libm-narrow-types-float128-yes +libm-narrow-types-float128-alias-yes = \ + s_f64xFf128 \ + # libm-narrow-types-float128-alias-yes +libm-narrow-types = \ + $(libm-narrow-types-basic) \ + $(libm-narrow-types-float128-$(float128-fcts)) \ + $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) \ + $(libm-narrow-types-ldouble-$(long-double-fcts)) \ + # libm-narrow-types # Type specific routine support. # @@ -115,33 +307,65 @@ libm-narrow-types = $(libm-narrow-types-basic) \ # Finally, note that types is an intentionally recursive variable. # We only know the full set of supported types for the target machine # after the Rules makefile has been parsed. -types-basic = $(type-ldouble-$(long-double-fcts)) double float +types-basic = \ + $(type-ldouble-$(long-double-fcts)) \ + double \ + float \ + # types-basic # Like types, but includes types whose functions alias those for # another type. -test-types-basic = ldouble double float +test-types-basic = \ + double \ + float \ + ldouble \ + # test-types-basic # long double support type-ldouble-suffix := l -type-ldouble-routines := t_sincosl k_sinl k_cosl k_sincosl s_iscanonicall \ - e_rem_pio2l +type-ldouble-routines := \ + e_rem_pio2l \ + k_cosl \ + k_sincosl \ + k_sinl \ + s_iscanonicall \ + t_sincosl \ + # type-ldouble-routines type-ldouble-yes := ldouble # double support type-double-suffix := -type-double-routines := branred k_rem_pio2 \ - sincostab math_err e_exp_data e_log_data \ - e_log2_data e_pow_log_data +type-double-routines := \ + branred \ + e_exp_data \ + e_log2_data \ + e_log_data \ + e_pow_log_data \ + k_rem_pio2 \ + math_err \ + sincostab \ + # type-double-routines # float support type-float-suffix := f -type-float-routines := math_errf e_exp2f_data e_logf_data \ - e_log2f_data e_powf_log2_data s_sincosf_data +type-float-routines := \ + e_exp2f_data \ + e_log2f_data \ + e_logf_data \ + e_powf_log2_data \ + math_errf \ + s_sincosf_data \ + # type-float-routines # _Float128 support type-float128-suffix := f128 -type-float128-routines := t_sincosf128 k_sinf128 k_cosf128 k_sincosf128 \ - e_rem_pio2f128 +type-float128-routines := \ + e_rem_pio2f128 \ + k_cosf128 \ + k_sincosf128 \ + k_sinf128 \ + t_sincosf128 \ + # type-float128-routines type-float128-yes := float128 # _Float64x may be supported, only as an alias type. @@ -151,11 +375,20 @@ type-float64x-yes := float64x type-ibm128-suffix := l type-ibm128-yes := ibm128 -types = $(types-basic) $(type-float128-$(float128-fcts)) -test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ - float32 float64 $(type-float128-$(float128-alias-fcts)) \ - float32x $(type-float64x-$(float64x-alias-fcts)) \ - $(type-ibm128-$(ibm128-fcts)) +types = \ + $(type-float128-$(float128-fcts)) \ + $(types-basic) \ + # types +test-types = \ + $(test-types-basic) \ + $(type-float128-$(float128-alias-fcts)) \ + $(type-float128-$(float128-fcts)) \ + $(type-float64x-$(float64x-alias-fcts)) \ + $(type-ibm128-$(ibm128-fcts)) \ + float32 \ + float32x \ + float64 \ + # test-types # Pairs of types for which narrowing functions should be tested (this # variable has more entries than libm-narrow-types because it includes @@ -163,14 +396,25 @@ test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ # for other types). This definition embeds the assumption that if # _Float64x is supported, so is _Float128, and vice versa (they may or # may not have the same format). -test-type-pairs = float-double float-ldouble double-ldouble \ - float32-float64 float32-float32x float32x-float64 \ - $(test-type-pairs-f64xf128-$(float128-fcts)) \ - $(test-type-pairs-f64xf128-$(float128-alias-fcts)) -test-type-pairs-f64xf128-yes = float32-float64x float32-float128 \ - float64-float64x float64-float128 \ - float32x-float64x float32x-float128 \ - float64x-float128 +test-type-pairs = \ + $(test-type-pairs-f64xf128-$(float128-alias-fcts)) \ + $(test-type-pairs-f64xf128-$(float128-fcts)) \ + double-ldouble \ + float-double \ + float-ldouble \ + float32-float32x \ + float32-float64 \ + float32x-float64 \ + # test-type-pairs +test-type-pairs-f64xf128-yes = \ + float32-float128 \ + float32-float64x \ + float32x-float128 \ + float32x-float64x \ + float64-float128 \ + float64-float64x \ + float64x-float128 \ + # test-type-pairs-f64xf128-yes # For each of the basic types (float, double, long double), replace the # occurrences of 'F' in arg 1 with the appropriate suffix for the type. @@ -193,8 +437,17 @@ libm-routines = $(strip $(libm-support) \ # and we don't want to have to link every program with -lm. # In libm-calls (above), list m_foo in place of s_foo for any # routine that should be compiled separately for its libc and libm versions. -calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \ - s_signbitF $(gen-calls) +calls = \ + $(gen-calls) \ + s_copysignF \ + s_finiteF \ + s_frexpF \ + s_isinfF \ + s_isnanF \ + s_modfF \ + s_scalbnF \ + s_signbitF \ + # calls gen-calls = s_ldexpF generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s)))) routines = $(call type-foreach, $(calls)) @@ -205,8 +458,14 @@ libm-shared-only-routines = $(call type-foreach, $(calls:s_%=m_%)) ifeq ($(build-mathvec),yes) # We need to install libm.so and libm.a as linker scripts # for transparent use of vector math library. -install-lib-ldscripts := libm.so libm.a -install-others = $(inst_libdir)/libm.so $(inst_libdir)/libm.a +install-lib-ldscripts := \ + libm.a \ + libm.so \ + # install-lib-ldscripts +install-others = \ + $(inst_libdir)/libm.a \ + $(inst_libdir)/libm.so \ + # install-others $(inst_libdir)/libm.so: $(common-objpfx)format.lds \ $(libm) \ $(libmvec) \ @@ -234,42 +493,95 @@ $(inst_libdir)/libm.a: $(common-objpfx)format.lds \ endif # Rules for the test suite. -tests = test-matherr-3 test-fenv basic-test \ - test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \ - test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \ - test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \ - test-fenv-tls test-fenv-preserve test-fenv-return \ - test-nearbyint-except test-fenv-clear \ - test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \ - test-signgam-uint test-signgam-uint-init test-signgam-ullong \ - test-signgam-ullong-init test-nan-overflow test-nan-payload \ - test-fexcept test-fexcept-traps test-fesetexcept \ - test-fesetexcept-traps test-fetestexceptflag test-femode \ - test-femode-traps test-iszero-excess-precision \ - test-iseqsig-excess-precision test-flt-eval-method \ - test-fp-ilogb-constants test-fp-llogb-constants \ - test-narrow-macros \ - test-nan-const $(tests-static) +tests = \ + $(tests-static) \ + bug-nextafter \ + bug-nexttoward \ + bug-tgmath1 \ + test-femode \ + test-femode-traps \ + test-fenv basic-test \ + test-fenv-clear \ + test-fenv-preserve \ + test-fenv-return \ + test-fenv-tls \ + test-fesetexcept \ + test-fesetexcept-traps \ + test-fetestexceptflag \ + test-fexcept \ + test-fexcept-traps \ + test-flt-eval-method \ + test-fp-ilogb-constants \ + test-fp-llogb-constants \ + test-fpucw \ + test-fpucw-ieee \ + test-iseqsig-excess-precision \ + test-iszero-excess-precision \ + test-matherr-3 \ + test-misc \ + test-nan-const \ + test-nan-overflow \ + test-nan-payload \ + test-narrow-macros \ + test-nearbyint-except \ + test-nearbyint-except-2 \ + test-powl \ + test-signgam-uchar \ + test-signgam-uchar-init \ + test-signgam-uint \ + test-signgam-uint-init \ + test-signgam-ullong \ + test-signgam-ullong-init \ + test-snan \ + test-tgmath \ + test-tgmath-int \ + test-tgmath-ret \ + test-tgmath2 \ + tst-CMPLX \ + tst-CMPLX2 \ + tst-definitions \ + # tests ifneq ($(config-cflags-signaling-nans),) -tests += test-fe-snans-always-signal +tests += \ + test-fe-snans-always-signal \ + # tests endif -tests-static = test-fpucw-static test-fpucw-ieee-static \ - test-signgam-uchar-static test-signgam-uchar-init-static \ - test-signgam-uint-static test-signgam-uint-init-static \ - test-signgam-ullong-static test-signgam-ullong-init-static +tests-static = \ + test-fpucw-ieee-static \ + test-fpucw-static \ + test-signgam-uchar-init-static \ + test-signgam-uchar-static \ + test-signgam-uint-init-static \ + test-signgam-uint-static \ + test-signgam-ullong-init-static \ + test-signgam-ullong-static \ + # tests-static # The tested symbols matherr, _LIB_VERSION have been removed in glibc 2.27. ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes) -tests += test-matherr test-matherr-2 +tests += \ + test-matherr \ + test-matherr-2 \ + # tests endif # These tests use internal (unexported) GMP functions and are linked # statically to obtain access to these functions. -tests-static += atest-exp atest-sincos atest-exp2 +tests-static += \ + atest-exp \ + atest-exp2 \ + atest-sincos \ + # tests-static ifneq (,$(CXX)) -tests += test-math-isinff test-math-iszero test-math-issignaling \ - test-math-iscanonical test-math-cxx11 test-math-iseqsig +tests += \ + test-math-cxx11 \ + test-math-iscanonical \ + test-math-iseqsig \ + test-math-isinff \ + test-math-issignaling \ + test-math-iszero \ + # tests endif libm-vec-tests = $(addprefix test-,$(libmvec-tests)) @@ -286,35 +598,167 @@ $(objpfx)libm-test-ulps.h: $(ulps-file) gen-libm-test.py $(make-target-directory) $(PYTHON) gen-libm-test.py -u $< -H $@ -libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs cacos \ - cacosh carg casin casinh catan catanh cbrt ccos ccosh \ - cexp clog clog10 cos cosh cpow csin csinh csqrt ctan \ - ctanh erf erfc exp exp10 exp2 expm1 fma hypot j0 j1 jn \ - lgamma log log10 log1p log2 pow sin sincos sinh sqrt \ - tan tanh tgamma y0 y1 yn -libm-test-funcs-noauto = canonicalize ceil cimag conj copysign cproj creal \ - fabs fdim floor fmax fmaximum fmaximum_mag \ - fmaximum_mag_num fmaximum_num fmaxmag fmin fminimum \ - fminimum_mag fminimum_mag_num fminimum_num fminmag \ - fmod fpclassify frexp fromfp fromfpx getpayload \ - ilogb iscanonical iseqsig isfinite isgreater \ - isgreaterequal isinf isless islessequal \ - islessgreater isnan isnormal issignaling issubnormal \ - isunordered iszero llogb llrint llround logb lrint \ - lround modf nearbyint nextafter nextdown nexttoward \ - nextup remainder remquo rint round roundeven scalb \ - scalbln scalbn setpayload setpayloadsig signbit \ - significand totalorder totalordermag trunc ufromfp \ - ufromfpx compat_totalorder compat_totalordermag -libm-test-funcs-compat = compat_totalorder compat_totalordermag -libm-test-funcs-narrow = add div fma mul sqrt sub -libm-test-funcs-all = $(libm-test-funcs-auto) $(libm-test-funcs-noauto) +libm-test-funcs-auto = \ + acos \ + acosh \ + asin \ + asinh \ + atan \ + atan2 \ + atanh \ + cabs \ + cacos \ + cacosh \ + carg \ + casin \ + casinh \ + catan \ + catanh \ + cbrt \ + ccos \ + ccosh \ + cexp \ + clog \ + clog10 \ + cos \ + cosh \ + cpow \ + csin \ + csinh \ + csqrt \ + ctan \ + ctanh \ + erf \ + erfc \ + exp \ + exp2 \ + exp10 \ + expm1 \ + fma \ + hypot \ + j0 \ + j1 \ + jn \ + lgamma \ + log \ + log10 \ + log1p \ + log2 \ + pow \ + sin \ + sincos \ + sinh \ + sqrt \ + tan \ + tanh \ + tgamma \ + y0 \ + y1 \ + yn \ + # libm-test-funcs-auto +libm-test-funcs-noauto = \ + canonicalize \ + ceil \ + cimag \ + compat_totalorder \ + compat_totalordermag \ + conj \ + copysign \ + cproj \ + creal \ + fabs \ + fdim \ + floor \ + fmax \ + fmaximum \ + fmaximum_mag \ + fmaximum_mag_num \ + fmaximum_num \ + fmaxmag \ + fmin \ + fminimum \ + fminimum_mag \ + fminimum_mag_num \ + fminimum_num \ + fminmag \ + fmod \ + fpclassify \ + frexp \ + fromfp \ + fromfpx \ + getpayload \ + ilogb \ + iscanonical \ + iseqsig \ + isfinite \ + isgreater \ + isgreaterequal \ + isinf \ + isless \ + islessequal \ + islessgreater \ + isnan \ + isnormal \ + issignaling \ + issubnormal \ + isunordered \ + iszero \ + llogb \ + llrint \ + llround \ + logb \ + lrint \ + lround \ + modf \ + nearbyint \ + nextafter \ + nextdown \ + nexttoward \ + nextup \ + remainder \ + remquo \ + rint \ + round \ + roundeven \ + scalb \ + scalbln \ + scalbn \ + setpayload \ + setpayloadsig \ + signbit \ + significand \ + totalorder \ + totalordermag \ + trunc \ + ufromfp \ + ufromfpx \ + # libm-test-funcs-noauto +libm-test-funcs-compat = \ + compat_totalorder \ + compat_totalordermag \ + # libm-test-funcs-compat +libm-test-funcs-narrow = \ + add \ + div \ + fma \ + mul \ + sqrt \ + sub \ + # libm-test-funcs-narrow +libm-test-funcs-all = \ + $(libm-test-funcs-auto) \ + $(libm-test-funcs-noauto) \ + # libm-test-funcs-all libm-test-c-auto = $(foreach f,$(libm-test-funcs-auto),libm-test-$(f).c) libm-test-c-noauto = $(foreach f,$(libm-test-funcs-noauto),libm-test-$(f).c) libm-test-c-narrow = $(foreach f,$(libm-test-funcs-narrow),\ libm-test-narrow-$(f).c) -generated += libm-test-ulps.h $(libm-test-c-auto) $(libm-test-c-noauto) \ - $(libm-test-c-narrow) +generated += \ + $(libm-test-c-auto) \ + $(libm-test-c-narrow) \ + $(libm-test-c-noauto) \ + libm-test-ulps.h \ + # generated libm-tests-base-normal = $(foreach t,$(test-types),test-$(t)) libm-tests-base-narrow = $(foreach t,$(test-type-pairs),test-$(t)) @@ -374,19 +818,101 @@ $(foreach t,$(libm-tests-base),\ $(objpfx)$(t)-compat_totalordermag.o): $(objpfx)libm-test-totalordermag.c # _Float128x omitted as not supported by gen-tgmath-tests.py. -tgmath3-narrow-types = f d f16 f32 f64 f128 f32x f64x +tgmath3-narrow-types = \ + d \ + f \ + f16 \ + f32 \ + f128 \ + f32x \ + f64 \ + f64x \ + # tgmath3-narrow-types tgmath3-narrow-macros = $(foreach t,$(tgmath3-narrow-types), \ $(foreach f,$(libm-narrow-fns),$(t)$(f))) -tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp10 exp2 expm1 fdim \ - floor fma fmax fmin fmod frexp hypot ilogb ldexp lgamma \ - llrint llround log10 log1p log2 logb lrint lround nearbyint \ - nextafter nexttoward remainder remquo rint round scalbn \ - scalbln tgamma trunc acos asin atan acosh asinh atanh cos \ - sin tan cosh sinh tanh exp log pow sqrt fabs carg cimag conj \ - cproj creal roundeven nextup nextdown fminmag fmaxmag \ - fmaximum fmaximum_mag fmaximum_num fmaximum_mag_num \ - fminimum fminimum_mag fminimum_num fminimum_mag_num llogb \ - fromfp fromfpx ufromfp ufromfpx scalb $(tgmath3-narrow-macros) +tgmath3-macros = \ + $(tgmath3-narrow-macros) \ + acos \ + acosh \ + asin \ + asinh \ + atan \ + atan2 \ + atanh \ + carg \ + cbrt \ + ceil \ + cimag \ + conj \ + copysign \ + cos \ + cosh \ + cproj \ + creal \ + erf \ + erfc \ + exp \ + exp2 \ + exp10 \ + expm1 \ + fabs \ + fdim \ + floor \ + fma \ + fmax \ + fmaximum \ + fmaximum_mag \ + fmaximum_mag_num \ + fmaximum_num \ + fmaxmag \ + fmin \ + fminimum \ + fminimum_mag \ + fminimum_mag_num \ + fminimum_num \ + fminmag \ + fmod \ + frexp \ + fromfp \ + fromfpx \ + hypot \ + ilogb \ + ldexp \ + lgamma \ + llogb \ + llrint \ + llround \ + log \ + log10 \ + log1p \ + log2 \ + logb \ + lrint \ + lround \ + nearbyint \ + nextafter \ + nextdown \ + nexttoward \ + nextup \ + pow \ + remainder \ + remquo \ + rint \ + round \ + roundeven \ + scalb \ + scalbln \ + scalbn \ + sin \ + sinh \ + sqrt \ + tan \ + tanh \ + tgamma \ + trunc \ + ufromfp \ + ufromfpx \ + # tgmath3-macros tgmath3-macro-tests = $(addprefix test-tgmath3-,$(tgmath3-macros)) tests += $(tgmath3-macro-tests) generated += $(addsuffix .c,$(tgmath3-macro-tests)) From patchwork Thu Dec 28 17:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BolqM8BB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Ff80W6vz23d7 for ; Fri, 29 Dec 2023 04:21:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 048453858298 for ; Thu, 28 Dec 2023 17:21:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 561453858285 for ; Thu, 28 Dec 2023 17:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 561453858285 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 561453858285 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784036; cv=none; b=PwpQ125AesEZTHv4XsbtZuZuJeVT+73q71S6H9mnutULoVgu18yEvUngZpH7Jl+ByX4fvn+uGi1PwWEAKR6N/gSwHW0NWFCHKhFAZqVCJ1YdCr6o2hrmlDaopYCjs4YKklFyja97UT1vvoOHPNA8ON55ckv2toAnOE6R7dAGiEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784036; c=relaxed/simple; bh=icbRRebo28bwbUjUPuHOu3TxXraa51y2/MbekaP6VW0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HAb3z7j54+Hdqi2MOAqOgrCYWqYpIVMZYfXQrZMK9OlISEIa8kp8bH5yWLcdmEjZZXSrIKn9/GCsP3HNrhtAFbCNNvylev6hlINT2DKw20zJUBrdb2jrdqjWa98Br+yOZjK1rlhsKsnLSmBKdp1KJ9xdIz0cpb3qwuX5W7DSbJs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6d9ac5bd128so1319177b3a.0 for ; Thu, 28 Dec 2023 09:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784033; x=1704388833; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Huesn2m2L4ex/SQtx9e/pU9r+ZSuhfpItQ8FOCLXjKk=; b=BolqM8BB1EGpYGIcONVeiMPhiZp7Lk0r5MzbsTbc6+NJYX4IKuib4dmI2ifCNNEAnM 1NZ2GJl9U7vCjvNrGeQFstqFGpjMV18c37v/DMjQEcO2NqoOdxoPht4MI9qB02sOFLTV s8Qay3P2VkXuYLl/Hx/zjNESWqxFvQUn6adtXyeY8xaHA5xqKvpdtIxtQtXpJ9FMH8I+ 9pe5z3wm+a8hf24x6XUXRtNAw+fAipaFJTFUoDNAPFBFMoLf/qeEKOT9z+NdOX4mOYiA o1lPeCqwpDXSWk6RML3pz4LqdBXXQSV39O0ZCyuwH7p3aVenjJfoa45ZMrsNaBAUqmRz jmtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784033; x=1704388833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Huesn2m2L4ex/SQtx9e/pU9r+ZSuhfpItQ8FOCLXjKk=; b=k6VScDrE3HNA+/GE+cF0OXOVrjxkiKtB2sPu4NOvh5laZsFbARpnqdxETrQ/H9anSt 54P0Kq1ibHjuswJsBT0IGfERWE5BM8Vp5/0Uanrz5c3X87mkERo0P8CEut9Go73UJpe7 ofB5G76v0ov554kWeoT9JZPSgWCGJQPyIYRP0gUrpNptmCPdlqtmmXpXgqLIe0bXVB7h gLKXibXQegCuZV56dW1vlFELn7dXu6i8Xe6GTiZvm76Nlwc9g4JDHYrvpLVc8RDlFcTN 6TQo99BMlpveko0ZTjE6w08wDoxPfwdEc6E7RGzL4otdMFa0i7GhWvZPHl9Se+dWsLD2 OhmQ== X-Gm-Message-State: AOJu0Yw9BxrYhxxMqj3LGLlXeJkY+H3ioiZkTB/NJDDDjUpSpFGNGln1 uNtFkiv8at1C/Yqfs8a5i62zLB9kxdEsOrVW3pX1/sfLWGg= X-Google-Smtp-Source: AGHT+IGIcPlIlGGGZhT60GD3w2v2vEZ3fN6eIwOVRVN7apK06tSpb2RH+gcwSB2a87byrzeQNNIL7w== X-Received: by 2002:a05:6a20:734d:b0:196:65bd:7855 with SMTP id v13-20020a056a20734d00b0019665bd7855mr502116pzc.53.1703784033664; Thu, 28 Dec 2023 09:20:33 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:32 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants Date: Thu, 28 Dec 2023 14:20:16 -0300 Message-Id: <20231228172026.2013007-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org The ifunc variants now uses the powerpc implementation which in turn uses the compiler builtin. Without the proper -mcpu switch the builtin does not generate the expected optimization. Checked on powerpc-linux-gnu. Reviewed-by: H.J. Lu Reviewed-by: Peter Bergner --- sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile index 64317506c6..2f5c0eded6 100644 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile @@ -34,6 +34,12 @@ CFLAGS-s_modff-power5+.c = -mcpu=power5+ CFLAGS-s_logbl-power7.c = -mcpu=power7 CFLAGS-s_logb-power7.c = -mcpu=power7 CFLAGS-s_logbf-power7.c = -mcpu=power7 +CFLAGS-s_round-power5+.c += -mcpu=power5+ +CFLAGS-s_roundf-power5+.c += -mcpu=power5+ +CFLAGS-s_floor-power5+.c += -mcpu=power5+ +CFLAGS-s_floorf-power5+.c += -mcpu=power5+ +CFLAGS-s_trunc-power5+.c += -mcpu=power5+ +CFLAGS-s_truncf-power5+.c += -mcpu=power5+ # These files quiet sNaNs in a way that is optimized away without # -fsignaling-nans. From patchwork Thu Dec 28 17:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=gww5hQCH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1FgC0bn6z23d7 for ; Fri, 29 Dec 2023 04:21:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E2E23858292 for ; Thu, 28 Dec 2023 17:21:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id B9453385843E for ; Thu, 28 Dec 2023 17:20:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9453385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9453385843E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784039; cv=none; b=wmcJGmvmRv1qLriau1oeQwVeN8VAcd5B4Kn3S00t/6+H8hEl9HjKzMo8zowOOjsou0UsgfBB0jxqelRiIQ2bYffJL7eWnCSjc93qRoL8jkqe8zuPDu+5a9uzIUik+df0C4pAJyaO7jVOQY5IzI0c5LnnLlZ63xcNC0e+cbRmQ0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784039; c=relaxed/simple; bh=m9fTcXt2h+YDHnP5Nqh91hW5rgCc2fhNFFiV/dORuHs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JYDDSnRH2/hygIrLMLxjWB3kexDmMm5jo/OLzGrmH8cuB4XKZloh74IsRvjTXrgpvEcZISo6OAyUedu3iTYS5nlbT6lSoSG4h2YXeFha/lfrt6rL94PrPDYWOI2Q1Hb8EFhR4KNytvW2052xP2MAh1uxA3PGujAkCclwUNjRuoA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6d9bf6f24f3so1163590b3a.2 for ; Thu, 28 Dec 2023 09:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784035; x=1704388835; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vfEZIsPGLvLl4/X3BIN733T0zrZmwn4k8C+goMzfFGc=; b=gww5hQCH2O92c/gHFvQCb3zntcGm+UV5+JtAWhLzUo3tAW3DmH9d79h/fFiQtlniTX nwrGq4Kq2nDwVAMjQQQHhA4yDT1B3YSjmpp9YiUZJTlwxh7uuoVGOj5OCVsMiKWtZs5z qnQFxrH1hLZQ3a5JeI46MMVOQJbCCniQ90cmFpR8MMJXqI0jBX/fa0pC/ffjx6uIg4vf NSCB75MHnz1EB8VFqY19SsVEIVt3LNyTlm/GhcWOk9VVDoBXCDhxGBsz/Nxb4eCFhuUo 6/0vSIWU6tTr1syQ34jnTYaPHVoBDOTFg6SLuMyXBzChJq107ScOVJ5y1g/YnQ4Wsj+c m5Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784035; x=1704388835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vfEZIsPGLvLl4/X3BIN733T0zrZmwn4k8C+goMzfFGc=; b=ZSYDH+37QTpuTEz0urCylonDGwT98+12FRHQOSyb54AACLqAfgVOaauFvU9JP08vqY sCAZxlJmBhQ5Gkf0COeQGEy3Eq0mEaLXA0dct9z2x4K0lV1D7uaACnKB9J4xA6QtsG9P 4LiYbPDlKyQ52596bbBSqKvqJYJR14VUlq9R7C8TfK744Earrrjt9MbuyTEV0sPsQNmV 8Eefpsbalp/T4XeUBdP+jCvFU9NZq/LtbVKsYJDLtlwkcqunoV3tCMXuF9Fkfir++Zp8 JxbT2Icfh0rYk3XJEzbQhWV2UJnce5xX1F9HWs6tPJoF2jZw7imDzLOWxuoAn+Lp+XDW +TPQ== X-Gm-Message-State: AOJu0YzSXPkdlh5N6BcNKQ5eTpdfvxVfdDwgsAIDE2ThZ8xCIqZKzVQ0 p2s8xzyCV8zp37InJgXLXyA50arQIM4ZJK7tB12u36Dy/nk= X-Google-Smtp-Source: AGHT+IElNf/89Nholu10/dNkjihCHon/4NsWua2zhyAh1icTr9pgggu1p+bhnW/DEVaIr81aoGPU6w== X-Received: by 2002:a62:a518:0:b0:6d9:cdf5:cc45 with SMTP id v24-20020a62a518000000b006d9cdf5cc45mr2547665pfm.63.1703784035200; Thu, 28 Dec 2023 09:20:35 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:34 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:17 -0300 Message-Id: <20231228172026.2013007-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 5 +++ math/test-ceil-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-ceil-except.c | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 math/test-ceil-except-2.c create mode 100644 math/test-ceil-except.c diff --git a/math/Makefile b/math/Makefile index 5a912c55bd..4fc7842313 100644 --- a/math/Makefile +++ b/math/Makefile @@ -498,6 +498,8 @@ tests = \ bug-nextafter \ bug-nexttoward \ bug-tgmath1 \ + test-ceil-except \ + test-ceil-except-2 \ test-femode \ test-femode-traps \ test-fenv basic-test \ @@ -989,6 +991,9 @@ CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans) CFLAGS-test-nan-const.c += -fno-builtin +CFLAGS-test-ceil-except.c += -fno-builtin +CFLAGS-test-ceil-except-2.c += -fno-builtin + include ../Rules gen-all-calls = $(gen-libm-calls) $(gen-calls) diff --git a/math/test-ceil-except-2.c b/math/test-ceil-except-2.c new file mode 100644 index 0000000000..c25956a402 --- /dev/null +++ b/math/test-ceil-except-2.c @@ -0,0 +1,67 @@ +/* Test ceil functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* ceil must work when traps on "inexact" are enabled. */ \ + b = ceil ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-ceil-except.c b/math/test-ceil-except.c new file mode 100644 index 0000000000..cd0717a96f --- /dev/null +++ b/math/test-ceil-except.c @@ -0,0 +1,85 @@ +/* Test ceil functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* ceil must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = ceil ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = ceil ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=D0BBR/r5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1FgJ42MVz23d7 for ; Fri, 29 Dec 2023 04:22:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 885953858291 for ; Thu, 28 Dec 2023 17:22:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 54E873858282 for ; Thu, 28 Dec 2023 17:20:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54E873858282 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54E873858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784042; cv=none; b=bNcfJvgDJX4waOgLdk8Cz6Ma8J62ZKR5H0ilqKkJOjn2q4XNJB+K0lWDAPsMOGvbeFbGEXZZRmwta6GHwd9w3y4hpopxUAiERaJ8HWs9hIEPaiLo5F6oJ1UNt0G6rZAfclK8WzDcp9BHnQIKLiKnpGIXunxukOJxvHhpP0dRRHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784042; c=relaxed/simple; bh=0Lx1BUvKNpjpegvnNvDiRteHtbH/ad96hxjvyKtSttM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=aWGuUl/XwtTx5sf4t8ACkWc3AM3nO3AS0cGHf2jXf0DWKwxKLj8j38cG333vfa09t8UxLAEgjbKtPtU7Xslsu9HMy+qeaKDxXws5+33Q2nkI7jiWadsdIuvQswOQmxxJ9DCW6r+5qKiAZ/qYkfhNPOj/sTkoron6E4lumoAlKAg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d9aa51571fso3074092b3a.3 for ; Thu, 28 Dec 2023 09:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784037; x=1704388837; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R/imacu5+KSGgiyc9Jl0JvYjneQJ+wlkM+brgCqe4fI=; b=D0BBR/r5aMAMG4TA++GOm3/X492vTMNa4SmlN02+HVcF3wVnlGnwYYzchoTDeX3BQb Mvx748fOLzStjYVxsndVcY5J3gI/AnVI26FJxQVwyOG5AC/z/A7mFNsZN1BqbKPG6KV4 bRmaz6sx05D5zTOUe4mu/LVd1TnNVpCvddyiWzYtOkGnv5aFn7zlakeCa2WzZuZEyCCi fEhSWn0cHeamJCYYqtJCwOklYy3FXPye5Cv1DPfEho06QG6T1SlKzSLQykDOzRkisLJU Qn2h14enYxGEnEx/31or6YIh8PEDMC/ls98smvxXEnq35I71mojWIuUL/Dy2LeqEknxa iWsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784037; x=1704388837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R/imacu5+KSGgiyc9Jl0JvYjneQJ+wlkM+brgCqe4fI=; b=T14p8cZsjvnPbE3zpynO+aiextnGdIZbsG8bhRuTm8yifa6h3PC+r+N+4kz+sCX4qK lSIedp4Sksa3vGI5W9OEa9yhODOQBVzrvuLK1Y3olaNv+RD3HL0CRadgSDv0EmNodjZ0 fxFpzazcYI/WEAE00bufqVG9BdnskpJfxmr5K9rcJJMsq/AVP6bqiDp84ZxqeAH1na/2 mGKsjEKwMKP3bqnWo4i6QGnsSwzR8UytAuc6Diiw//Md4q0XnbZRdTlgHZJrpJ8ypHKd n62Em6SuDQo5X0XXW11lRxQgCI1/R7LGlHl+/wQV2S4FSaMNwKz1Z+s7DpG9DP9R/YAq eBAA== X-Gm-Message-State: AOJu0YwHkLNpTueOofFAuK/x+uhEUj5td+up9m9ZFzEbIHFDsVesj0Tt sWWIYzUqmn8wcDHqneMaM8yK6heLBZHY+eACi7dL35bOrw8= X-Google-Smtp-Source: AGHT+IE3UovchsoAaOVJmXqwVxxRKyxZB1Ghz8aV1OmV2yXuFb8fgV5RABfc1uWMtaY8w97QP0RBQw== X-Received: by 2002:a05:6a00:1254:b0:6d9:c784:9c8f with SMTP id u20-20020a056a00125400b006d9c7849c8fmr7263700pfi.36.1703784036807; Thu, 28 Dec 2023 09:20:36 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/12] math: Add test to check if floor raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:18 -0300 Message-Id: <20231228172026.2013007-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-floor-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-floor-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-floor-except-2.c create mode 100644 math/test-floor-except.c diff --git a/math/Makefile b/math/Makefile index 4fc7842313..19e234874a 100644 --- a/math/Makefile +++ b/math/Makefile @@ -512,6 +512,8 @@ tests = \ test-fetestexceptflag \ test-fexcept \ test-fexcept-traps \ + test-floor-except \ + test-floor-except-2 \ test-flt-eval-method \ test-fp-ilogb-constants \ test-fp-llogb-constants \ @@ -993,6 +995,8 @@ CFLAGS-test-nan-const.c += -fno-builtin CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin +CFLAGS-test-floor-except.c += -fno-builtin +CFLAGS-test-floor-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-floor-except-2.c b/math/test-floor-except-2.c new file mode 100644 index 0000000000..01b22f984b --- /dev/null +++ b/math/test-floor-except-2.c @@ -0,0 +1,67 @@ +/* Test floor functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* floor must work when traps on "inexact" are enabled. */ \ + b = floor ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-floor-except.c b/math/test-floor-except.c new file mode 100644 index 0000000000..fe77866ddc --- /dev/null +++ b/math/test-floor-except.c @@ -0,0 +1,85 @@ +/* Test floor functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* floor must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = floor ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = floor ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ArIHerb8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fgv4t3Lz23d7 for ; Fri, 29 Dec 2023 04:22:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6E0E38582A1 for ; Thu, 28 Dec 2023 17:22:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id AA3AC3858C36 for ; Thu, 28 Dec 2023 17:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA3AC3858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AA3AC3858C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; cv=none; b=glUrAtWwnH98HNZs+b3oyteM3qeUCbVtNqsiOOQQODPFigwqlY2hgZXXMjVIc7CqgsAXm7h4myMyL/Iv/yGkJnWI6pKm20vPmqDOl6myOLq1wPsI9s1jGIl0fed3fIMdJBDkYLEtUADgRN/uk4fSqlA8uSW+oBl+dASLR3neD6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; c=relaxed/simple; bh=BHsfWGMLCtderjDLsmqkIZqsyGo5HVhwwXD4ZWsLGH8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MKizTBTbnNAV2UM8DDGHep+rsMX0UC5XMx+T/xzcYxlV9AtZLhEVOMqLXt8UKQYqA32aYgfIL2g4xYbdIBR+HM0SpNWZnA7yBI9GjYzXyl8vvjx6xXb/plqBeIJdIWcLcXh3wAUubCUW6tZ2vAmy4n3QE7eclvJ0fG1GRLTtVH8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-594965fbb3cso2032994eaf.1 for ; Thu, 28 Dec 2023 09:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784038; x=1704388838; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jYCR0Es9t9c5ayU2ClkHYO27pEUSNvGDcJ87yJNQxaE=; b=ArIHerb8OyRYHuUZ+iuemwksf4zBamvfHcEBIkPTn47QhmnkfDDINQbOTI30OMpeO9 z3sn/EJe46sV6jTSRpCoL26wvhUMVao0Thbwrtw5SWPSfO4i0af9hC1/UpqQMxg8vs70 HI1zQQvqJ7vUsLQp3rpvYlRFz6moTs5DKbflm3nEvHk1IvHtZYAypSRm1EfvcoxaP1wk o0s3Mjn9BDlA6dvm+enGBO8/W8PVU/BXhmoAcLI80AUbau7j9ySNFSII9r4Q3tEpWIh9 JdbyieFpvoMGFFOaFvqk8k272/LQWg5drH5F8+kq/VcaCEyT+LBlLCvBOtw+zSTK1HnW gwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784038; x=1704388838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jYCR0Es9t9c5ayU2ClkHYO27pEUSNvGDcJ87yJNQxaE=; b=obzQxm3coRLa1YwHZ0U6JuFn7KCdpHcq05b11vSePLo4T3hxKAO6PiZYnBvHeQsY6h vXCdaYHJpPIuQEJZwR/ShVWf58xQNe6K7M83kjkhB7hZXT6hSJ2TpQ2Kxy11M/mUUXSF xoD5sKYCZ40HKFbRRcIuiq4BBeiZxmfOvDqm9yUNv39V/02zG0sTWakWWK872Q3Jn/HT TOnZLUFj0wR2A8OSe6Lc6hem1BhxWrxdVXwd9VcuYNqQ5Q06PcwV42t+TZULsM3h8LJt XO8DVgG9JoJolUV0L6FnuN/rOX0ZfUwpZ/hi9JbK3HEYmQsVoqG7aczERueWoNs5NRPb ksSQ== X-Gm-Message-State: AOJu0Yx7FzZQ1XdapOjHXAtExtYCZibQb6k2I9Cl2O0M4WH2aejzFdfA WXqUNHDiFWelnJhfbDMauSeMym+ikILpMwT181KONqilRSg= X-Google-Smtp-Source: AGHT+IHtp5mYozFlkvXjiwr09F6Sx40HybM7wforbE4VVMZzqSgn4BrnL4/9lXBMODdM9s2xmfF7uA== X-Received: by 2002:a05:6359:4c06:b0:172:f31a:6bfb with SMTP id kj6-20020a0563594c0600b00172f31a6bfbmr14104588rwc.51.1703784038309; Thu, 28 Dec 2023 09:20:38 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:37 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 05/12] math: Add test to check if trunc raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:19 -0300 Message-Id: <20231228172026.2013007-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-trunc-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-trunc-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-trunc-except-2.c create mode 100644 math/test-trunc-except.c diff --git a/math/Makefile b/math/Makefile index 19e234874a..7ae107170c 100644 --- a/math/Makefile +++ b/math/Makefile @@ -541,6 +541,8 @@ tests = \ test-tgmath-int \ test-tgmath-ret \ test-tgmath2 \ + test-trunc-except \ + test-trunc-except-2 \ tst-CMPLX \ tst-CMPLX2 \ tst-definitions \ @@ -997,6 +999,8 @@ CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin +CFLAGS-test-trunc-except.c += -fno-builtin +CFLAGS-test-trunc-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-trunc-except-2.c b/math/test-trunc-except-2.c new file mode 100644 index 0000000000..29716efc0b --- /dev/null +++ b/math/test-trunc-except-2.c @@ -0,0 +1,67 @@ +/* Test trunc functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* trunc must work when traps on "inexact" are enabled. */ \ + b = trunc ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-trunc-except.c b/math/test-trunc-except.c new file mode 100644 index 0000000000..c9e341de0d --- /dev/null +++ b/math/test-trunc-except.c @@ -0,0 +1,85 @@ +/* Test trunc functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* trunc must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = trunc ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = trunc ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=C/uLHaEr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fgd46pbz23d7 for ; Fri, 29 Dec 2023 04:22:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71EDA38582A3 for ; Thu, 28 Dec 2023 17:22:19 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 432AD385828A for ; Thu, 28 Dec 2023 17:20:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 432AD385828A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 432AD385828A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; cv=none; b=epLeJeG6PuC3P3fzIaZrZsM3y13xgZdLgsYD4/DmuR0qoehksDR02fA6Wc4E/l3TcLs6jqqyGdlV4W7n6k0KRCsMcEX/lCf/2SUbRxUDp7k+fizTwJqIrx1Ul4yWCxslYIVJk0WQ/0fxq0bBmIP1nrcRyQBVl0ustEqwWhWgSLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; c=relaxed/simple; bh=7LbP0bZAu0KPhjphY2MiUjWs3zO1ol6lJ3u9fop6GiU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=gLMA9PWh/9w7WsWoF2cU5UobxKKaLQBmPqshD7MaeEw0MBwI7mVmpc7gHliCiZd8K9DPr3vBqkA7mi4kAvedDjdrDklraLaIIYOz7awLr1a2r50J9YD6UEl9baUdhF9P41G3Dr+hDRCGIqnk4NHPPuNl6+rL9B1o6lPRWg5s/ac= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6d9b267007fso1235078b3a.3 for ; Thu, 28 Dec 2023 09:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784040; x=1704388840; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G7DAyBPI7iRaNkh70Jq9qwomvSbfKt3p52V+XD56U4Y=; b=C/uLHaErfdqusaP2ZYoc2bwjhQwhouOLaEfXmOAQ331UGQW0epkhMN03WqqgNVnsho SypYA9nr/TgNjAot+/BLcEsX5+OnTS/SXgWgzQT9aIMVUIgWg4J0IUNBf/AQHSBy9j7B 86/TiWLzPt2P4nvxdSkAB+/hyjbHlTeinsmwb4cbi7NeoB7HmlFuBGKuEPerOo/rvFhX 6FkeF8mH/oXD9YHxxwxWvE55U3KYg8BtfAX6dBtXPk5WkE9OJQRRiluka7OJHgzpxGk7 F1zzhCTrriSR5n9xH+qTr2RA4jx0L1dtV5e9Qwx15CIGDc4usR/68uwt7dHHUT07QIvC AgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784040; x=1704388840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G7DAyBPI7iRaNkh70Jq9qwomvSbfKt3p52V+XD56U4Y=; b=TyDotLdjgmOj06zbBAwPrdS8bE6MxFbqzc9znc7+gXmPuNZzoceIzcLemb9n1vN3SY OJTk9AEE6zI/vSXY7K4LRInPiPEj8sdZLPnYjxB1uAkjQY0aoEAiC5URtwzh1LMhk4Ek D2xFyo4l6RkOW/2iK3tWl8XgrWR4gIHIVgy3bxxyUM7M7jtHCQnpPKHrBKCbCfQ/77Ow pJLQX28IXF7zxZ3hBmFWmMo5ysIlbRjiGgkOJcffxkvHn8Un62bEuHH1sg4Eatm5muwU BXOnzEhSpqPkheUY7BfDi6h35jTWR4cL0ID43Y9yhRYae6jz1wSrZ0d7a7w1aVTQIn/f ytOQ== X-Gm-Message-State: AOJu0Ywl7jnSIaDstAvChSBz42rD9xfA+JdVBAZI6Mhfmsd2q3MF9Ivg iyNEmg33I+RKC2UzLfXbJcuv+nJSu90ytEqjW7Oc+LOGCQ8= X-Google-Smtp-Source: AGHT+IF0ObW69ro8jl4W69KPRkirMv8TEZ1gSGZfB7vz3q0TzumnMx7B5nV2flUEj2pFGpVI6Fa2MA== X-Received: by 2002:a05:6a00:1acb:b0:6d9:ed3e:af5b with SMTP id f11-20020a056a001acb00b006d9ed3eaf5bmr2960269pfv.2.1703784039799; Thu, 28 Dec 2023 09:20:39 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:39 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 06/12] math: Add test to check if round raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:20 -0300 Message-Id: <20231228172026.2013007-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-round-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-round-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-round-except-2.c create mode 100644 math/test-round-except.c diff --git a/math/Makefile b/math/Makefile index 7ae107170c..dfe24a8c03 100644 --- a/math/Makefile +++ b/math/Makefile @@ -530,6 +530,8 @@ tests = \ test-nearbyint-except \ test-nearbyint-except-2 \ test-powl \ + test-round-except \ + test-round-except-2 \ test-signgam-uchar \ test-signgam-uchar-init \ test-signgam-uint \ @@ -1001,6 +1003,8 @@ CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin CFLAGS-test-trunc-except.c += -fno-builtin CFLAGS-test-trunc-except-2.c += -fno-builtin +CFLAGS-test-round-except.c += -fno-builtin +CFLAGS-test-round-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-round-except-2.c b/math/test-round-except-2.c new file mode 100644 index 0000000000..dffc02e91f --- /dev/null +++ b/math/test-round-except-2.c @@ -0,0 +1,67 @@ +/* Test round functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* round must work when traps on "inexact" are enabled. */ \ + b = round ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-round-except.c b/math/test-round-except.c new file mode 100644 index 0000000000..cd43c964ab --- /dev/null +++ b/math/test-round-except.c @@ -0,0 +1,85 @@ +/* Test round functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* round must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = round ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = round ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=lf3OxaO+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fhw2VYsz23dZ for ; Fri, 29 Dec 2023 04:23:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3567A3858002 for ; Thu, 28 Dec 2023 17:23:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6ABD03858286 for ; Thu, 28 Dec 2023 17:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ABD03858286 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6ABD03858286 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784045; cv=none; b=ta+vPxfR1A9yScNVfuOmBlL9Bnx8Sy0Iale/LxnAtltTTzjlyzMpHBPANbnLAOjhteYYu7f9aiQ7xjSYS0BIDdFaXyKul2aZPNBfeo/VwqGRf0vchMovSzIk0hQEMsVzmLY8NcudWe5SCKIM+AJAChRAkJFge+8BKIZNp9vQuhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784045; c=relaxed/simple; bh=iccIFjLRfp4IHbcfo8DyFNAJ2jg78Xfxd8GNb3JH0HQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=d6UEUu2I78J+IOjJ4KOuaaneObIRUnlGt16t5OsIBu21/6uyjCRKLVlK4rksBKpirhVaqHXIrh/55QfYcI2NmLJl7W0kCfzb84OTs7jIsCNWymnfLVxLZLcPWwB1y6Ldlg9Py+J/7QHJQkJVyqnuJSCNPwzvmF1YtraDbIKB+WU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6d98f6e8de1so1816266b3a.0 for ; Thu, 28 Dec 2023 09:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784042; x=1704388842; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+NbhUyx25vjdS6Rhk8Zdirg4THsnNQU8QR+D2Twnb8Y=; b=lf3OxaO+2++mHcgLPUcJ8hoRAaKVySBYWlV9DM+EeCW4VA3jd7R74PcIZE/QBbxqIa LIHG65dRID87m0ulroRU+y3J3JqV4sfcqUQ9saDPwP3UelaJPYIbfsHCXJbmaI5Itjp3 1e8ku+iySIzq/Ye1Po6fD28flipkMNZ1UQZvXjnfe7u1nc+BgUbSqICTk5rzZTalTHj0 7ShrcKxYWSKCPOCK72USCfjmwCRJoYyGBDer9+2pCmMWKmBuMHc+jaoFiIjXs8tqdNxv b1MDN3rfpRGr6RnZrBMrSqWkj5TH1sYrSZkft5ZI9xWmC+vbphKdYanyPpl4xMFS6jT8 kDmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784042; x=1704388842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+NbhUyx25vjdS6Rhk8Zdirg4THsnNQU8QR+D2Twnb8Y=; b=KyFKjgYMF81qXoWuu2imI1TiiVIFLeR2sqds7RaZn7AokGwNrbX5UYKR13QFf2TvjP C5TWmix37xqoricBivTLMmoHqgZhS7AH+wwJkETJOudjMc2iExkl2DMX3tMgpISN6u1y 0tQakDIh3UOY6pq9zp4zHL3aRb/Zg1k/oz9W65XbbCsgaBMkgv7VY1iyNSxVadpMvRY/ 83gBFpj/v7NG1syHydNceynGJh+uKL+Vi4FdxJHbsE+Iyij1XKQZ46LOeQk6t5jmCvnE 1THzdO1mNrnsyunO+CGtihlVn8jeeq0hhkvfuJfuHS2D8ilf26hPg0KiQMxz3jS2OB8m sOLw== X-Gm-Message-State: AOJu0YyeyB4mWOyUCVKSFShSsIxKZSkUD1XrIbx7De0rNwEYxkbDZkSM Z06KerFKC8bPxMNUNfOKuu/c1xu3gpE1culUgH/+bziKXcQ= X-Google-Smtp-Source: AGHT+IHpQa5a2nKchnuSq3qCKs0k6VktQddaHmdqQWT5BcKJxuzEz2pRHTlT9HwAqcO/ZnyzBXIZ+A== X-Received: by 2002:a05:6a00:1889:b0:6d9:bcc4:4d08 with SMTP id x9-20020a056a00188900b006d9bcc44d08mr3402608pfh.56.1703784041773; Thu, 28 Dec 2023 09:20:41 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:41 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/12] x86: Do not raise inexact exception on ceill Date: Thu, 28 Dec 2023 14:20:21 -0300 Message-Id: <20231228172026.2013007-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_ceill.S | 39 ------------------------------------ sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_ceill.S | 34 ------------------------------- 3 files changed, 38 insertions(+), 73 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceill.S create mode 100644 sysdeps/x86/fpu/s_ceill.c delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S deleted file mode 100644 index a551fce7f9..0000000000 --- a/sysdeps/i386/fpu/s_ceill.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__ceill) - fldt 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c new file mode 100644 index 0000000000..96c901e383 --- /dev/null +++ b/sysdeps/x86/fpu/s_ceill.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +long double +__ceill (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/x86_64/fpu/s_ceill.S b/sysdeps/x86_64/fpu/s_ceill.S deleted file mode 100644 index 16dbecd56d..0000000000 --- a/sysdeps/x86_64/fpu/s_ceill.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - - -ENTRY(__ceill) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl -28(%rsp),%edx - andl $0xfbff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) From patchwork Thu Dec 28 17:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ygkCwpnG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fhz1Yvyz23d7 for ; Fri, 29 Dec 2023 04:23:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C17038582A9 for ; Thu, 28 Dec 2023 17:23:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id EB19C385829F for ; Thu, 28 Dec 2023 17:20:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB19C385829F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EB19C385829F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; cv=none; b=RSAfK6lcOS+aGQpnarAXQJ2DgvaFj4RAcc2YrI1OBnln9jQK504hD7V4JlGoBwdQkSq4VKvtxUQC+l1K6yhN0Okj6Q6tl7VYEMr7DBTGhzkQlKrSV3ntrZ1kzdDWK0BrVH5kKf8/1ZuzFV3habzbac5fBLnU+UIetqFXpIJt8Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; c=relaxed/simple; bh=lnHACzmx0VPJkz/RKocha4/9EZ6Ug05fxfsGdijW3pA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=vzwp/sbi267Ir0LBQhw4aH540lgDuZTBcmPkho4KBzwhOLPhX1FojjM9qXe40EtNocjGrI6N8vX6Gw5zC0ncGmJXIeqy3qShrrcwqnEkPqyj+IADc4ghwdsE+YoGzHZrXJdlyidh0o1W02SHAUL+3y7q3aaddSbhj1NGGAuDMec= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5cd8667c59eso4686883a12.2 for ; Thu, 28 Dec 2023 09:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784043; x=1704388843; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ygkCwpnGMJKFQy8UAzN2zLa/oKdDiUHJsl7qLxPsoxtuwgyEujGy0II7ym5/ZNu6Th L/aeAnimDe36HcWEEl/OO+srDtTvAJURThB0eF9/tQ6pnl5GuyID/RTHXmBT5BWlJJIV Y0IuPfs6SyYdlpvvBt1PTVGJDvWAREaZamaOSMnRWI2pVkuP8Ui3kf6tJwUK4u4nHGQl 6G0PKQPGT+BNBdD2vVJeP0C5/w9FuP+Plp1yy3ABbFYAgulZ3XMR1llS4GT2g/GEoMvB D4bIBR6fJFxOMM+TURJjRv2xnFEv+bG5mtYdABatF9Ynxzw1SscACUuIoFKQ46WQHX50 T69Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784043; x=1704388843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ZPsYKXm/dEm7Jh9DxH7P/pCEEdKA5dKtCZCPC6F4R4041C4Iu1X2roGWZSdo3oj9E2 N+zaCNn26fQ+TtHCSoIMkxa+KRGThfslrj0XLYEPdghlO1mRT4kk06eJvVC3eZ66MuRt zuKS4Z6MYb3ReRhywMhShEPcS9TNcdYlZDihuRo8Nxflgi2y2UVXLUg9IQinhOU6HGYZ baPCcS2AT70rSi9jyIy1VH5vmid63MBXwREYF4hodgjXKeeHHuH7C7GC4RbW6Y/o8glX 663EuZ7Eh0Cws82fzz0Vh7PLhVWVW5JMJVNxwZoofkHX6lJp1jvB1ERoU0Cc4xcLEowC KPgQ== X-Gm-Message-State: AOJu0Yzk5AqarLYLuws3mPg7mLXxniI0opX1vQWkv7Lr5otSRwDhPB0W 7oZaRGXqUV9rdb4a8/Cjd+OKcScJRPMPvN7xBivwz+E22E0= X-Google-Smtp-Source: AGHT+IHvi4n6gWixn3VdHvcfYG7rkfm+xkwnH0I3sISUsrhvYy66AjjdU0mcSeR5zopqj1ERN5FWig== X-Received: by 2002:a05:6a20:7d83:b0:196:376c:fb73 with SMTP id v3-20020a056a207d8300b00196376cfb73mr2481823pzj.49.1703784043551; Thu, 28 Dec 2023 09:20:43 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:42 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 08/12] x86: Do not raise inexact exception on floorl Date: Thu, 28 Dec 2023 14:20:22 -0300 Message-Id: <20231228172026.2013007-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_floorl.S | 39 ----------------------------------- sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_floorl.S | 33 ----------------------------- 3 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floorl.S create mode 100644 sysdeps/x86/fpu/s_floorl.c delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S deleted file mode 100644 index 3ec28b477b..0000000000 --- a/sysdeps/i386/fpu/s_floorl.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__floorl) - fldt 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c new file mode 100644 index 0000000000..edaf5e954f --- /dev/null +++ b/sysdeps/x86/fpu/s_floorl.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +long double +__floorl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S deleted file mode 100644 index b74d1a4d6b..0000000000 --- a/sysdeps/x86_64/fpu/s_floorl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -ENTRY(__floorl) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl -28(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) From patchwork Thu Dec 28 17:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hfHNu1bz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fj92LXdz23d7 for ; Fri, 29 Dec 2023 04:23:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 517AD3858286 for ; Thu, 28 Dec 2023 17:23:39 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id A459D385841A for ; Thu, 28 Dec 2023 17:20:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A459D385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A459D385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=dZ14rv0TxeNQYJ+twBCvLUwYkc2i/EciN5xnbBS09BGnARE9zZ8YoMU5mLrLigpFWnQkOCFhnbvX2gAx69l6BZCe2T4NhBMy5bWwgBytV0EaQo8rkGXyq4U/66VEaZ+Q51N+/7AYirixYbCahNdQSR8aA3Ck+2v5NA5IdniBLYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=APmPneg9e9H+Z2LkqQtP3cFsiPjFfGEFus6reP8+IKA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ccKLH68LmlM7qtaZWLngubf2zjcFYwtl4ya4Jqbaw9wOzV4lXIcBZbXo1J1jU0iW98C49k0YfAK/YQ0lpdpCs25jkAyJkZJZaPn0v864aqI36acv44A5ZSIWb2f7xYMXgN1DjYsZQxw7OjfzKhY2FFr87FVTyN3Y0R+6Acj3nsA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d9cb95ddd1so951728b3a.1 for ; Thu, 28 Dec 2023 09:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784045; x=1704388845; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=hfHNu1bz7HelpE2e1+2/trkP9pTjiksPsmQeKzaXOsvkc7h+tR8tZcs8ObpeC5EOpq 1UGcYHJlYeH7+gYwPGmSPnBhqsDd74FWoGq0jV1Yp4vSmB56qwT7ki2IaeVqWMbUG+Qm p+UwUiS2dgteyKaeJk0JsjHdKyQEk8ErlYYI9APBzxJDk/xwqZnIsyG5SCsv5sYWMXbp 8I0BU/gkaVDuSYxsTARQ3vEtGlMLK/BQUmyRA8eE0iUeqIvUMu9MYIBStTV0/buFdxcB 9ESRGgTwUn+jGLHr3AlGIxN/GMqldpjeI41AxvCzMWqm+fa6znlaEaI9mXQRjL5GegzL qeMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784045; x=1704388845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=isczxbK2obvy4sclu8lqtgD9pVKxrH4oQwwDmP7luPtphmKZYuuBFOfvXF82+1qLDR hh3cr0zZwhVCdPQ+H6jNmmdfdu/oBKFRkQjgwnlaJSkLqdPKghOuOw6LgBZKFMMVaEtt fYr4OWXucbNv/RaYKn+B2F2rDc4jYf8imDOSqts+Nvq/wFGG1U1ooWGQWVqWAWZxBe+N D0qFcROKdIA3hxn/krCTFgXeLr0d2YxofEv/gM3aMpiS2IJ86+Id/0eugPT5WZeEVdtu 8QKveXKVIij+XYmFso2k+dNAFF5dK8DDNFdpHEJZcREoOlqH1WmBJu2KIkCmKXa283rb nunQ== X-Gm-Message-State: AOJu0YyDpoIgge33Lb5XcgtO3jYIrH2FsRLZxyfB0hTAG5tSBPnBqfed VnIDzcSSIgqr1SlYQcgVY/Ow9bJ/ALUnlZdPwIfXkNy0pFg= X-Google-Smtp-Source: AGHT+IEN19E3DABrDMWgZfgJauw0QvVGTGqdBXI+YH8TVNoUYrakJd+YhuV2D+nF4DlQ6MEDyDrhMw== X-Received: by 2002:a05:6a00:1d28:b0:6d9:aa4b:3800 with SMTP id a40-20020a056a001d2800b006d9aa4b3800mr4363471pfx.19.1703784045189; Thu, 28 Dec 2023 09:20:45 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:44 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/12] x86: Do not raise inexact exception on truncl Date: Thu, 28 Dec 2023 14:20:23 -0300 Message-Id: <20231228172026.2013007-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++---------- sysdeps/x86_64/fpu/s_truncl.S | 36 ----------------- 2 files changed, 19 insertions(+), 57 deletions(-) rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%) delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c similarity index 61% rename from sysdeps/i386/fpu/s_truncl.S rename to sysdeps/x86/fpu/s_truncl.c index cfd4e75252..249b307004 100644 --- a/sysdeps/i386/fpu/s_truncl.S +++ b/sysdeps/x86/fpu/s_truncl.c @@ -1,5 +1,5 @@ -/* Truncate long double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,25 +16,23 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT +#include +#include #include -#include -ENTRY(__truncl) - fldt 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncl) +long double +__truncl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_ldouble (__trunc, trunc) diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S deleted file mode 100644 index 8d319e68b0..0000000000 --- a/sysdeps/x86_64/fpu/s_truncl.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Truncate long double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY(__truncl) - fldt 8(%rsp) - fnstenv -28(%rsp) - movl $0xc00, %edx - orl -28(%rsp), %edx - movl %edx, -32(%rsp) - fldcw -32(%rsp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - fldenv -28(%rsp) - ret -END(__truncl) -libm_alias_ldouble (__trunc, trunc) From patchwork Thu Dec 28 17:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=HAgC43CF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1FkC3ktsz23d7 for ; Fri, 29 Dec 2023 04:24:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C9743858C36 for ; Thu, 28 Dec 2023 17:24:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 2279F385842C for ; Thu, 28 Dec 2023 17:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2279F385842C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2279F385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=hWbjip6P/6m23UFMTJyB3c6/AQWfl7sHyOuvxVPqKtGhRGovT7o/aaN+9Xz4Pdk365F+BmbDmVSihUWFSSN7zvX/dLrzXiI44MBneiKtSoPxb7GU/piUWhyUrUSyEmveyyYi2L8IjA5ZJiMzxOlrTN6AhsSWyytLBOBexltMPa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=Fyf/Ec11BxuJoVcKbZMh9bSiwbRwSaF+LgXnKbza1ec=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nhnmu1y9zb//deB+0vkeNXy8mro8ngp78FUv4OU9SLrzD9HA3Odc5b3r2brBKEFuIu5S7WDMkebZvGRlxKDc3IqOCBxjSy/qmPpyoJ+6h6elY6nQmAz1w5ID5hjEpbZA5qhdJRgVoIaCrKCwZUf6dGrZEBWe4aSLfeoeeivHWfk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6da202aa138so503178b3a.2 for ; Thu, 28 Dec 2023 09:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784047; x=1704388847; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=HAgC43CF9fzxzztqH1plIs90oARd7bvVCIRGpktj8r4/S807oGf0zRPTNyqd2CqdN0 7Bx/K7npnwNeXnYm6wAxQJ4ldqjdlkTFOkkunt+zEKBa+INvSWDqt06ieGOImFQB+0Mr RxJifIa/fauXAxgaiEHPCJVoKzJz7MbbyJmIkon5iP+CaK/fFrznWpDATSCkil+8J9DH 9Ok9ZKWi7y8aqa92qi67Nm+EoKgAa9x6Cjt1XsoZK/DGAbAdysi0pyf1st25K6ll3gCO P9guPr9KbLPmadPdNHDFWuWqLq5a1YbFdUCW15OzA9jIdlwfWqJ8DEzuqlgalT7bimdW GW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784047; x=1704388847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=QwHqZtdsbvjeTFnj4G2+QDXpdEZPtLzEeSlat3+GAGKIGYYisvV1DTo03dMkQBu7iE XQ+wULbK2IVxCz0b8fJ8vY5PoxcNYq4sMznEjRVANmAi6YsGqM4oLIrB88acobLIwuDL fcs7Q9gYARrdnBBIVGTSQGjOqjX7mpg9KYCAudMvlO6AMYkROujtO+ozqOdSypMq/g+n U9AuGZdNCXDroGkSNpopl3nFloD2o36VXv6Hwt8h4BSorK9Wx6ta3ZcQyeYlv2RjJUXG /Pb/TyLB01vRTsUAXeFBVYD3/2a3NCevVHtdRPPDfsVpKIGsi1JgSud8hjEyhwAcQIk7 VVUA== X-Gm-Message-State: AOJu0Yy8/UXFePx86MNxyLo3sj8KBE9FjkORZfJ/oHwNnTpuDFznp5EU ZKImo7QvWEV7jydrSCDmP/0eLcyYZM9bKDQtVSEWA1xRVJ4= X-Google-Smtp-Source: AGHT+IHCjtb/YruFJbopFGK7c8jYWBsHyQkARb00REpT/zz3sP/3hB/+e3Q1zdkWuP69LQEJoFANhQ== X-Received: by 2002:aa7:90d8:0:b0:6d9:aa94:a38b with SMTP id k24-20020aa790d8000000b006d9aa94a38bmr7859888pfk.5.1703784046618; Thu, 28 Dec 2023 09:20:46 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:46 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Date: Thu, 28 Dec 2023 14:20:24 -0300 Message-Id: <20231228172026.2013007-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_floor.S | 34 --------------------------------- sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_floorf.S | 34 --------------------------------- sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floor.S create mode 100644 sysdeps/i386/fpu/s_floor.c delete mode 100644 sysdeps/i386/fpu/s_floorf.S create mode 100644 sysdeps/i386/fpu/s_floorf.c diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S deleted file mode 100644 index 7143fdcc9a..0000000000 --- a/sysdeps/i386/fpu/s_floor.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $") - -ENTRY(__floor) - fldl 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floor) -libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c new file mode 100644 index 0000000000..90ba61da92 --- /dev/null +++ b/sysdeps/i386/fpu/s_floor.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__floor (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S deleted file mode 100644 index 8fad9c0698..0000000000 --- a/sysdeps/i386/fpu/s_floorf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") - -ENTRY(__floorf) - flds 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorf) -libm_alias_float (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c new file mode 100644 index 0000000000..0e7e8223a8 --- /dev/null +++ b/sysdeps/i386/fpu/s_floorf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__floorf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__floor, floor) From patchwork Thu Dec 28 17:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SaWtldn/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fl42Cnqz20Rq for ; Fri, 29 Dec 2023 04:25:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3173C3858D39 for ; Thu, 28 Dec 2023 17:25:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id C39E038582B3 for ; Thu, 28 Dec 2023 17:20:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C39E038582B3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C39E038582B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; cv=none; b=tkl7m4dQZg2WCspwGkBRlYqpyiIRbt6pxHiliOuSr97LeKJ7Tv+LR4tIk5Y8KHLwMRV54WYTwm+r+9+WPdJfHRDVXoDGnivZBODrJl3Tb76HXELzrMLQc0Gb4P1CfE1x305W2qMS+e9mhe+NSm3m7j+vl/kIcA1rWWumJ3VG744= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; c=relaxed/simple; bh=NO5XYk+qncsfEiGHVdntk+f4jc1W/NdZGwux3E14TC4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=v+C4SddEYw2EYLqt7ehzVLVmOIj0pv+QLIem63QhNw7KQqHdu1Q2NgYI8S21yFZGisGAunMUZ1iIhFOQxteKS63++hXHGs4ii120s4aMnUL2ND6ydC2caPzgcPRg5rOWoslI1lF7HVfx2oxdGLJhtUi1YzyUbPAN+7H/YFIouK0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-204520717b3so3526554fac.0 for ; Thu, 28 Dec 2023 09:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784048; x=1704388848; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=SaWtldn/FvbagikVsIIFDuanFVapTPuKPstGiRwy6T4ima2UhZk1PSEmZP8d0aMmOI I5M5Y6R9v4PNPJ6w7GnpwZfEhxh4QyTwWsmRllW/Bd8WoeGFWSexzgfnGW1+hlyl/Ots TIaN24KaCh8+nP1gM3ksoCdQZ9HWmDJmdsEWkqkzSZHLykI4XAWK+7MhodC0AmMXFxNH of6V8x9OiL9VZUkGUlgv0VEfu8A/UTxA79rDMsskPvqxjhfw9Fpjfh4pCg35nSHZDfqs SarZNPmKPhz1xDxvb3A9fAALTZq96Qb14t5UayYbwn+Wj68RMa7TO32oAirtQFZt0b3u hGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784048; x=1704388848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=q7KjCQli2LqrGVhnskE6tuvtXk292lU4uwe8oR3ilSq4iiWNq4eJVyj5V6AWl9FclT emApqvgjgFMFJLT8SG33c/3L0fKXBv0aasaXSCcMDdzkpkrTYHCJ4ZSpWxPOT5dECdev hU8G/BuZnXg0snp3f5jpbAvRGc7xLW9W5gO9yNwdn788oS/w8R/IcH9vBfYEDczio7p1 O0ffS4PcsXV/EFKJ1iL1nRxvLT5LSK03QQZOv+PHbIntpwpUTAjbJjpjHfTkG1YqLVUa baS6mXBmHSPMDfHHM5fD5iAjRDRRbbhYguE5Vc4TWtKZMPsAemycnvonMlcz9gW3+L2/ gVdw== X-Gm-Message-State: AOJu0YztAlzcEblQR/gTMlBuUCvaDcl97kv2n2sDx7yTDzOX6kJmUnP5 P/B2OxX8HLfsY8quEK07o0Q6khM4U62+NiixumuIcq5KI44= X-Google-Smtp-Source: AGHT+IELnyDB1/KFwWvH4miA1oACJLW5PbtlA5ky8MvBs6pSk61W7xaRz0F8nKb5Z7fQkF1fwvwzuw== X-Received: by 2002:a05:6870:2194:b0:204:4093:b89b with SMTP id l20-20020a056870219400b002044093b89bmr12228921oae.31.1703784048180; Thu, 28 Dec 2023 09:20:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:47 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Date: Thu, 28 Dec 2023 14:20:25 -0300 Message-Id: <20231228172026.2013007-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_ceil.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_ceilf.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceil.S create mode 100644 sysdeps/i386/fpu/s_ceil.c delete mode 100644 sysdeps/i386/fpu/s_ceilf.S create mode 100644 sysdeps/i386/fpu/s_ceilf.c diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S deleted file mode 100644 index 99984f9b8d..0000000000 --- a/sysdeps/i386/fpu/s_ceil.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $") - -ENTRY(__ceil) - fldl 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceil) -libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c new file mode 100644 index 0000000000..ec948ef83f --- /dev/null +++ b/sysdeps/i386/fpu/s_ceil.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__ceil (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S deleted file mode 100644 index 03e8e22609..0000000000 --- a/sysdeps/i386/fpu/s_ceilf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") - -ENTRY(__ceilf) - flds 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceilf) -libm_alias_float (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c new file mode 100644 index 0000000000..36159610b2 --- /dev/null +++ b/sysdeps/i386/fpu/s_ceilf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__ceilf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__ceil, ceil) From patchwork Thu Dec 28 17:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LBhBwTNj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1Fhv6qnfz23d7 for ; Fri, 29 Dec 2023 04:23:27 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED4A8385829B for ; Thu, 28 Dec 2023 17:23:25 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 5C9973858002 for ; Thu, 28 Dec 2023 17:20:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9973858002 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C9973858002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; cv=none; b=x+srz2HO+ijxljjJWIg9wEAZpUEyVy2g+F0YR13s8sqPxJTyz02BsUgkjrZj9K+ee4RaWyUOCBI4PTdzb8DLEAh+Uw2tTISrUBljxeLV+1t6uDo0nPxqrjW22RMET6DRtZVCn9HrM1irr8J7di2K8y9MfILRqCmFO8nSj0QRjl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; c=relaxed/simple; bh=D1yDmR5qcLzfU4mCnflNeZnmm0PZuf08hTKF6ZZ10IM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GxTqAiNm6UwtRLI05xnTLAkq1R9kqm3bD59TEE6LgaZOYUK4/+oYP9z699/dHFfWjYLw1e6To0iAgcZxPCaLOTW+AF9D1E6zSVMxXP37/in00hGCHKeWO+Aqj0tJsell62Q1bc8bESUvTBEtRLgzMTuzCHjJXMNFWCuFGh+J7YU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6d099d316a8so5751034b3a.0 for ; Thu, 28 Dec 2023 09:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784050; x=1704388850; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=LBhBwTNjWVb4e+UW3nRpwPUQnWmInQ6B1ITIm4AUxlw6jfaRM55vhVCVTXAnizGj00 NKlFckWiZqL2jDG6maKE164b9SrsUaluas7ohB4iuQ/NzZYkKnthOtEnbycC8oBBph55 2WJUWlNR085ljNuSU+BgQo7UZjvWv+qKDC45VIje0T+J8epsX/M1CMwYgh5BFUSfaKCS kEY3M8l5YPmx/5fULJuMjrOiFzRdnZN/KnXU4XGl/D9VOTyWXS7N/HcVFm8JYX5LlRYq G1J0CzsqPHweGp/AsuRjYogGGGiorqIdl5fysJC7Lq6sReHMDS47oOJbhigq5QLIaG/X PpCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784050; x=1704388850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=fLIDCgR/CCzXizrNptN7zXPhywGYcNzUvd33SY0cw9qRVIvvVQw70sJUdOmG8wIavC ZatNFxLAZId7x1OckqeQFEekH4Xb64EjN9GK5I19FGn1gvkUjOJWbdvDKkA/+3fff0rW dbBOBcDXBwp4Ta9uPbOkODz5O4YlBP32VaaHt5Dxa87X/aEfnSlzPDUBnCKIaj8br99i 7i+MLOHiD99H8KKdADHZKuEVkftcOEtjdggQppxi2K2Z5vWapsny0PnurJD3q6NoJjDL NxiUtuHFmJyPNz6UTGxFg78U4cqefRAea0ktxqY3cEpgsn/3LWXlYA5lx9rFzsqu7fvU enfA== X-Gm-Message-State: AOJu0YzMpDwnYiE0THw1ZDhMeNJ/usSMgsj4QIZT0kHrPF4MWTff7UK6 w6Yo6m8vetp0j6kczJyNSvh1uo4W8Xy+9Tjss1O7XvYznUo= X-Google-Smtp-Source: AGHT+IG0WzU0x386mNRUnMOmq27w8C50H4kezqTksXfD3xGEZ04e+e9wQRKWjDJoZaAT/Jag7ILIxg== X-Received: by 2002:a05:6a20:8825:b0:195:bda4:4b2d with SMTP id c37-20020a056a20882500b00195bda44b2dmr4972533pzf.102.1703784049819; Thu, 28 Dec 2023 09:20:49 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:49 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Date: Thu, 28 Dec 2023 14:20:26 -0300 Message-Id: <20231228172026.2013007-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +++++++++++---------- sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++---------- 2 files changed, 38 insertions(+), 36 deletions(-) rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%) rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%) diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c similarity index 61% rename from sysdeps/i386/fpu/s_trunc.S rename to sysdeps/i386/fpu/s_trunc.c index 145288bc8e..b071ad9750 100644 --- a/sysdeps/i386/fpu/s_trunc.S +++ b/sysdeps/i386/fpu/s_trunc.c @@ -1,5 +1,5 @@ -/* Truncate double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__trunc) - fldl 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__trunc) +double +__trunc (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_double (__trunc, trunc) diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c similarity index 61% rename from sysdeps/i386/fpu/s_truncf.S rename to sysdeps/i386/fpu/s_truncf.c index 7bdf0e5111..86d46ff660 100644 --- a/sysdeps/i386/fpu/s_truncf.S +++ b/sysdeps/i386/fpu/s_truncf.c @@ -1,5 +1,5 @@ -/* Truncate float value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__truncf) - flds 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncf) +float +__truncf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_float (__trunc, trunc)