From patchwork Wed Aug 19 15:39:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 40298 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 6C2943870849; Wed, 19 Aug 2020 15:49:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C2943870849 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1597852162; bh=jCz6xkZ8yizLsXJnm6kksuC+KuPgoYPhc42qhwjrj7w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=HwCnmBYufKq9iSaJIN3j4NYe7yhnxeCy1PPm4HdPW9DJqjXiFkCwtNQMzkZBLiQcI 5HJhMmEu5r3/uPu99ln4hMe7DE9uqeAeLW+HOzvSFrWG359OXFCIf6Nq7P9UdiIiKR iTuVNfirPtgQzh+brEuISXErDJfbv+ERQzuCyJH8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by sourceware.org (Postfix) with ESMTPS id 51B023842435 for ; Wed, 19 Aug 2020 15:49:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 51B023842435 IronPort-SDR: a3mwtRKk3WuoOErY1Hj9HegJ93kzjG/Ha9OEHuruu5z6BaHvoyaaoNbBZt0q7tip3g1YczWq84 GDSP+Wed0tuj45Bc6F/xUhtBbOcGgUqjYvSZ2c7OUjVzvBO5NJUmzud1b2Oc+3HhJM4EUAeXDe Vde9Nnw5AnMVL5OPWIbxxth+UE1KLqkTcgAFpwRO4UkmoMPHq3M8ulSrtl3LJBnQIbJvirY8Yh hAngw4Zlyltm+REEo+YuyasE7OzELz7aqfmZSwze4BL1ySGlefmLygsLqI2/uMKg5b/3w04bbO Ogs= X-IronPort-AV: E=Sophos;i="5.76,331,1592841600"; d="scan'208";a="254766972" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Aug 2020 23:49:19 +0800 IronPort-SDR: GAdpKDjEE8RBR6ZKclXxeGH9L926BvlyLG/3+myrH7wpie+9tb8uupazRyRGC7jNnTwv2kD/tu tyNpXkDhXVng== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 08:36:16 -0700 IronPort-SDR: 5wLWxiRaydVIe8AqYMbDCBClGUrbo+CEUJiK+O+zZ4PjthVNNLBSyGhZA8BaFyuNuBMPuXaS1D SK3au4FP7jbA== WDCIronportException: Internal Received: from lpt-kalia-a.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.58]) by uls-op-cesaip01.wdc.com with ESMTP; 19 Aug 2020 08:49:18 -0700 To: libc-alpha@sourceware.org Subject: [PATCH v5 12/17] RISC-V: Fix llrint and llround missing exceptions on RV32 Date: Wed, 19 Aug 2020 08:39:10 -0700 Message-Id: <9a6481b56407222bdfd75ead53b2429871a295ad.1597851293.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alistair Francis via Libc-alpha From: Alistair Francis Reply-To: Alistair Francis Cc: alistair.francis@wdc.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Zong Li Conversions from a float to a long long on 32-bit RISC-V (RV32) may not raise the correct exceptions on overflow, it also may raise spurious "inexact" exceptions on non overflow cases. This patch fixes the problem, similarly to the fix for MIPS, ARM and S390. Reviewed-by: Maciej W. Rozycki --- .../riscv/rv32/fix-fp-int-convert-overflow.h | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sysdeps/riscv/rv32/fix-fp-int-convert-overflow.h diff --git a/sysdeps/riscv/rv32/fix-fp-int-convert-overflow.h b/sysdeps/riscv/rv32/fix-fp-int-convert-overflow.h new file mode 100644 index 0000000000..ddf9e3c351 --- /dev/null +++ b/sysdeps/riscv/rv32/fix-fp-int-convert-overflow.h @@ -0,0 +1,38 @@ +/* Fix for conversion of floating point to integer overflow. RISC-V version. + Copyright (C) 2020 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 + . */ + +#ifndef FIX_FP_INT_CONVERT_OVERFLOW_H +#define FIX_FP_INT_CONVERT_OVERFLOW_H 1 + +/* The generic libgcc2.c conversions from floating point to long long + may not raise the correct exceptions on overflow (and may raise + spurious "inexact" exceptions even in non-overflow cases, see + ). */ +#define FIX_FLT_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT_LLONG_CONVERT_OVERFLOW 1 + +#define FIX_DBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_DBL_LLONG_CONVERT_OVERFLOW 1 + +#define FIX_LDBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0 + +#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0 + +#endif /* fix-fp-int-convert-overflow.h */