From patchwork Fri Apr 29 23:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 53367 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A79A385736A for ; Fri, 29 Apr 2022 23:55:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id ED0A23858405 for ; Fri, 29 Apr 2022 23:55:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED0A23858405 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-pj1-x102c.google.com with SMTP id bd19-20020a17090b0b9300b001d98af6dcd1so11787250pjb.4 for ; Fri, 29 Apr 2022 16:55:37 -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=3fJD96RBrfp5MAzFsLwaDZu2c+AQdlPeKSMzmXLOjBY=; b=edDl3lTPqFd1caI6zdt3X4zZ9ecQ4te+mB8C3igelvtf288X5AEcgkr+oDXNxC4PHb a7G/zgT+mJ/lTv8R6hX0L7TArMbbvFL4dQY1d8WyVqE2kO5/Vwbw0VMCasba08xcJmGO xSrTpCgn1jd8ctlVx8XBOPa7CM7ZSGmWVXEM7KsRtpaiYa6GLV/F3E5HJwER2feI5dit bJjOKmZAMOT5YRb0snEb9MVyGjSGQlZ3H+DCbVideD2LG3XkwHp3fCn37F8wbivR1OOw xod9MpLjrQYYzw/MhOGbpWUkbebWB6l5C1ujWCKMUidUhnmGbTiNrmNmYXE9vbahV+C/ VNfg== 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=3fJD96RBrfp5MAzFsLwaDZu2c+AQdlPeKSMzmXLOjBY=; b=FVUstEYhv2654FojgoN1acWe4JWy/dGj2nl5G673xjmbWy6A6xfMEQ8p6n+kwX4PDJ FvVErqTtpawx7OtkQKd0RxOby0Coir7RUvXqq/CZX+MBaOkmNytOu4N19DeKctkXdnq0 7Vqh4u5hQPc5fqZV/aFMzDdRv8S4Z40/M6rQ8s7nxYYCMu/m1HbNKdZp52kx+dZNyiN7 FGieSs0k4SDHaIk9m4d4dxySfnB0+xon3/trYRS347PATHGLO1Gk1iiU2ymiySmwMadH VFuYfR5cyvRAFSv6D2Tyi0kR3h/EuEAGLgv7Nd1SAckLSEL9fHTrWuzHaNSCYEzSB2+s ERKA== X-Gm-Message-State: AOAM530LahO83/cIwEG0y8Me/IZQnywzZ9tYCfcxnUaHktJgUz0Q4PRU HwkbIZf+wjTpnBY5fa1DeYC2VQ== X-Google-Smtp-Source: ABdhPJzREVp62E5MD5rxZwateMXKKS9qDYRj4r3d1l87fjxgfxN/fDMxR/ny2iOMJSICV8039qMpwQ== X-Received: by 2002:a17:90b:3b89:b0:1d9:ab51:52b with SMTP id pc9-20020a17090b3b8900b001d9ab51052bmr1610289pjb.1.1651276536853; Fri, 29 Apr 2022 16:55:36 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d3ca00b0015e8d4eb298sm160480plb.226.2022.04.29.16.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 16:55:36 -0700 (PDT) Subject: [PATCH v2] Disable tests that require fesetround() on platforms without it Date: Fri, 29 Apr 2022 16:44:52 -0700 Message-Id: <20220429234451.14068-1-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 From: Palmer Dabbelt To: Kito Cheng , gcc-patches@gcc.gnu.org, joseph@codesourcery.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: 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+patchwork=sourceware.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. --- Changes since v1 <20220428155514.27063-1-palmer@rivosinc.com>: * Checks all defined IEEE rounding modes, rather than just using "1" (which isn't itself a valid mode on all systems). The original goal was to avoid depending on the macros being defined in the first place, but after thinking about it this seems better anyway as IIUC users are supposed to be testing for those before using them already (the trick here is that RISC-V may choose not to implement these at runtime, even when they are defined). * Those atomics were a known issue, not sure how I forgot about them. --- .../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 +++++++++++++++++++ 8 files changed, 42 insertions(+), 7 deletions(-) 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 {} {