From patchwork Fri May 13 17:21:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 1630879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20210112.gappssmtp.com header.i=@rivosinc-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=jk0douV2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L0Fxr5qCGz9sFr for ; Sat, 14 May 2022 03:29:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0FE9395B822 for ; Fri, 13 May 2022 17:29:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id D432C3840C15 for ; Fri, 13 May 2022 17:28:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D432C3840C15 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-x42f.google.com with SMTP id y41so8225770pfw.12 for ; Fri, 13 May 2022 10:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=subject:date:message-id:mime-version:content-transfer-encoding:cc :from:to; bh=Q6/djXFPFHhOY/hhFLIzSEzVxaPaoSI3Fg5mEGbL6sU=; b=jk0douV2ol4VlE5tiMk6M9HhNVNeGh9l00XgP6N4NTpHhVPblzYJOiw63/X9SZ7ogO FYY8dD3AeDGXzfqVGJpeHbfEZJm+qpqX2x2vMwDyqRcz0qnPjQgeQ6kHJs+/if59Wh82 TsQWBrorWDTpbF71fMwnOThxBDNz0oGWl4fdwlR6rCsgi6iyf0owBOKPsMHzfnQ3r8Lc /DpG6nRT67rYIAGAA9jn1hvOplmJomqFah3kXwfoqfsDALZWYUSTkgvcVR9ZY8hpGcAY gnxNzePQ7pZe0HYdM0C+G6IlgGIB5Jh8Cf1kS6p7ULeiemc3opaDjPVzgBEXpwB2xW47 sEEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:date:message-id:mime-version :content-transfer-encoding:cc:from:to; bh=Q6/djXFPFHhOY/hhFLIzSEzVxaPaoSI3Fg5mEGbL6sU=; b=k4QbA0+/2r7J5KkKg0c80nSQpDckVqybgDpYTDA+zHCj2taYoUH+B0Xczw8fJBE4cw r3jj09hL9Daix8Ze5XCoAjOPGN9VvCComNKd5NSTlogAuFY90spIHIMPl1iXMt7uFKgQ TNvNg5xRgAwv9QGMkPomBmCz12z8Fi79TfikC9UaqfVG5/gNMhzBN9G6Ob65nEGndHhz A2jh0WApte2JcwnSRjTve3MDHwrsInnSsRkHZjZQQaOGLVd7KkDQ8VLw5MF0oR5tOZia PMOGSktTOktliLlPETXZnceiR6DFu65eKZCurnn+A9zzQ7MGVku5yim+HXTsIA1lLdTu MiFQ== X-Gm-Message-State: AOAM5321TnnCl3HJUN22nDYgxjkcT3e476juk4LrMjhbrZHxof/QpmB0 xLUHnRPJ8rM9MmrZBPCH6f7Jzg== X-Google-Smtp-Source: ABdhPJxM/ycZhiyDklkxzkqtMDBJWCvTIaMx8sh53i7ApYoYm2SOAP24bhxbRJuOyz8tNZwk8wNB3w== X-Received: by 2002:a63:894a:0:b0:3ab:2edc:b973 with SMTP id v71-20020a63894a000000b003ab2edcb973mr4852913pgd.219.1652462917817; Fri, 13 May 2022 10:28:37 -0700 (PDT) Received: from localhost ([2607:fb91:7983:4f59:bf03:cc22:3fc5:9000]) by smtp.gmail.com with ESMTPSA id t19-20020a170902b21300b0015ef63f2382sm2109075plr.231.2022.05.13.10.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 10:28:37 -0700 (PDT) Subject: [PATCH v3] Disable tests that require fesetround() on platforms without it Date: Fri, 13 May 2022 10:21:18 -0700 Message-Id: <20220513172117.12698-1-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 From: Palmer Dabbelt To: gcc-patches@gcc.gnu.org, jeffreyalaw@gmail.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Some tests check for fenv and then proceed to use fesetround() directly, but some platforms (at least RISC-V soft-float) have fenv but don't support rounding modes. This adds a DG check that fesetround() actually functions, which is then used by all the tests that call fesetround() explicitly. gcc/testsuite/ChangeLog * lib/target-supports.exp (check_effective_target_fenv_setround): New function. * gcc.dg/torture/fp-double-convert-float-1.c: Check fenv_fesetround. * gcc.dg/torture/fp-int-convert-float128-timode-3.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-2.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-3.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-4.c: Likewise. * gcc.dg/torture/fp-uint64-convert-double-1.c: Likewise. * gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise. gcc/ChangeLog * doc/sourcebuild.texi: Document fenv_setround. --- This was approved with the doc change in the v2 <9de73b8a-3f70-2f6b-e0d9-0fa4298c8823@gmail.com>, but I'll hold off a bit on committing it just in case anyone else has feedback. --- gcc/doc/sourcebuild.texi | 4 +++ .../torture/fp-double-convert-float-1.c | 2 +- .../fp-int-convert-float128-timode-3.c | 2 +- .../gcc.dg/torture/fp-int-convert-timode-2.c | 2 +- .../gcc.dg/torture/fp-int-convert-timode-3.c | 2 +- .../gcc.dg/torture/fp-int-convert-timode-4.c | 2 +- .../torture/fp-uint64-convert-double-1.c | 2 +- .../torture/fp-uint64-convert-double-2.c | 2 +- gcc/testsuite/lib/target-supports.exp | 35 +++++++++++++++++++ 9 files changed, 46 insertions(+), 7 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 613ac29967b..793e2f353e8 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2560,6 +2560,10 @@ Target supports @file{fenv.h} with all the standard IEEE exceptions and floating-point exceptions are raised by arithmetic operations for decimal floating point. +@item fenv_setround +Target supports @file{fenv.h} and any standard IEEE rounding mode that is +defined is implemented in the environment under test. + @item fileio Target offers such file I/O library functions as @code{fopen}, @code{fclose}, @code{tmpnam}, and @code{remove}. This is a link-time diff --git a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c index ec23274ea98..656e5c345e7 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c +++ b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c @@ -1,6 +1,6 @@ /* PR57245 */ /* { dg-do run } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-additional-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c index c445d10522e..499e8c0cabf 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c @@ -4,7 +4,7 @@ /* { dg-require-effective-target __float128 } */ /* { dg-require-effective-target base_quadfloat_support } */ /* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-options "-frounding-math" } */ /* { dg-add-options __float128 } */ diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c index a82f03d079c..3f91f8f3833 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c @@ -2,7 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c index 707d539335f..816fcb1120e 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c @@ -2,7 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c index 09600f90903..6337a6d3f1e 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c @@ -2,7 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c index fadad8c3198..43aeb81a602 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c +++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c @@ -1,6 +1,6 @@ /* PR84407 */ /* { dg-do run } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-additional-options "-frounding-math -fexcess-precision=standard" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c index 952f96b33c9..d380b4a80e8 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c +++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c @@ -1,6 +1,6 @@ /* PR84407 */ /* { dg-do run } */ -/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target fenv_setround } */ /* { dg-additional-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 2d5d0539bb4..bd4dab0a9ad 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -10685,6 +10685,41 @@ proc check_effective_target_fenv_exceptions_dfp {} { } [add_options_for_ieee "-std=gnu99"]] } + +# Return 1 if is availiable and supports fesetround. + +proc check_effective_target_fenv_setround {} { + return [check_runtime fenv_setround { + #include + #include + int + main (void) + { + #ifdef FE_TONEAREST + if (fesetround (FE_TONEAREST) != 0) + abort (); + #endif + + #ifdef FE_UPWARD + if (fesetround (FE_UPWARD) != 0) + abort (); + #endif + + #ifdef FE_DOWNWARD + if (fesetround (FE_DOWNWARD) != 0) + abort (); + #endif + + #ifdef FE_TOWARDZERO + if (fesetround (FE_TOWARDZERO) != 0) + abort (); + #endif + + exit (0); + } + } [add_options_for_ieee "-std=gnu99"]] +} + # Return 1 if -fexceptions is supported. proc check_effective_target_exceptions {} {