From patchwork Tue Nov 8 04:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lee X-Patchwork-Id: 16856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2480601wru; Mon, 7 Nov 2022 20:40:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM7hD8ICoAfhUprOgET+2z2BijKXqszNem2GRlLLf4s1YMIAhuy2etxOWJS6g5zp6OAGYEZu X-Received: by 2002:a17:906:8473:b0:77b:efa8:50e4 with SMTP id hx19-20020a170906847300b0077befa850e4mr50692784ejc.250.1667882401187; Mon, 07 Nov 2022 20:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667882401; cv=none; d=google.com; s=arc-20160816; b=s2YfJjYGyXiVkXcn3wKLb6ajTZgz4gQF8cf6gfy3QubxZyO3QuqisB0r9BL/ynm08R jWidRBO+yOCFlgQ2LjCX2yH/E9HaNoKATICKZUaB0Yg32EsV4lBcyCVK3lww2sItjwwk GGnQ2jl6N/MTS5m5oiYGkrupLRyo9dBlAt1SvQ+4aT4tNJLqSyMGA2LWN3446u9/GlcA O2mo5988zgiAFsoZm3Vget2+w8q46q2PZRpiUTPfEZLNKlPC/vYqTlN5t9kOukt3XgpE iU0ssWZz3Q8gZB2+rCtJyjgXzIZSrgTU4Upo9olWW9OFMjiudLJNPz62OoeCvKy0+B90 08pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=jghq9ytaN4LNt4kOEeP/4K8gtrieZjfrnDV796EtJMM=; b=UujpNJkviAjpauudxwleIrFvpv8UKjNgDYgxfYk1l3Sjqv2oV0KnA4NqYY6NpmUhHr 076bDt9zCzvKm4HHWGAt5LhNIUWxpdffWZIkFq7KikoB2ySnXoJeuobEDXf91sptWBS2 7t2JIQtynjCCDYm61ML8WbGMhPLQJmsj4HTbiBn9R3ls4GbXCebgpBM+S/hOokWw8h19 zO/ufwnQuufPE+wdA2zjOBHcUOA8YtKLx87ADy3i5Y9QA3y6/rMaWSO5QvRORQeQ/JIU /goOk78nXQ7BxiUI6MScgKV35C28zNKk0HtHIMup25jHpqTjXF5eTGb9bmAcnAllIdPe w9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=RjVwhrGi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g8-20020a50ee08000000b004614db9083csi10243324eds.313.2022.11.07.20.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 20:40:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=RjVwhrGi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 899D4385829E for ; Tue, 8 Nov 2022 04:39:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id D4DB73858C00 for ; Tue, 8 Nov 2022 04:39:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D4DB73858C00 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-pl1-x636.google.com with SMTP id io19so13127078plb.8 for ; Mon, 07 Nov 2022 20:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jghq9ytaN4LNt4kOEeP/4K8gtrieZjfrnDV796EtJMM=; b=RjVwhrGiZ2qlIGU80vvvrkeK1r/RCXnbrrEcCygxCtOjVIN2QDtZNYXPt6HwL4kjAB IQ2sclKjqq9Dgn94uh3wJ0wNd+iWAF3PudlsVBh83Y2fd9wSczSDUo18WHqdBJgBLOS6 X0rHWQw0KT1OvgKgm/nWTiaubtWEFhlSgsq9xqdtoXQz1rP2XYshg708AJyZhHYkMW4Z dlC08Zu61NdI8sZto1uZh7luxL4Gfi22PlJjOxHl2e+NqPnWjIWFmkwgN9Xx5tTcVG8m 4FtPoFmZNDwPQ5sLu3w6EgJYPXy9CMZ2oXqNdo/HsJoDl2uuInmIB+YH1TeYU5dFNAv6 nW0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jghq9ytaN4LNt4kOEeP/4K8gtrieZjfrnDV796EtJMM=; b=BLAbup5OuqfmHlyAwi1V+zy9JrcEvy8Qe/uhd1IkSOEeWjqnlarYA0YeKjUNkTXckP ArfacKfzKrSDnSbQbZ6DF22xf9m1WIt6BRwzXDdH8bdX9ZF6SMFSuqRmPsMmo8idWV6X isUi1MUubwGqnSzsbCvo94orQ3J/IKcnGTlfVeotZIDZS9LcyqDL3Pq6Jr9KPcwg5fEt HipC1DJLIA+QGEdqMHQESTzv2oqWU7s77ftT9jZmNTjVdU4UYNoqKFl9sSY9qtmKZap9 Bd5quFxW8b6MxdTcSh3ejbj667F7mqEDKDf9Xvq3ZUOaCZVDHFpD5MolrHQqy9cC9tBF X8VA== X-Gm-Message-State: ACrzQf1dEPtgxPEAqbPdOIbHTD1aT+Wt9A24hMX2WyVyeajUkSUoEt6r aPhpVSeZ0HImxMNJmNgNWdhhGy7TpX8ZWx+s X-Received: by 2002:a17:902:a584:b0:186:6040:87f9 with SMTP id az4-20020a170902a58400b00186604087f9mr55301952plb.36.1667882368455; Mon, 07 Nov 2022 20:39:28 -0800 (PST) Received: from kevinl.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id w184-20020a6262c1000000b0056b9ec7e2desm5305991pfb.125.2022.11.07.20.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 20:39:27 -0800 (PST) From: Kevin Lee To: gcc-patches@gcc.gnu.org Cc: palmer@dabbelt.com, kito.cheng@gmail.com, gnu-toolchain@rivosinc.com, Kevin Lee Subject: [PATCH v2] RISC-V missing __builtin_lceil and __builtin_lfloor Date: Mon, 7 Nov 2022 20:36:58 -0800 Message-Id: <20221108043657.2064455-1-kevinl@rivosinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741276546651164958?= X-GMAIL-MSGID: =?utf-8?q?1748901456392602822?= The patch in https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599755.html was corrupted. I am resending the cleaner version as patch v2. Thank you! gcc/ChangeLog: Michael Collison * config/riscv/iterators.md (RINT): Additional iterators. (rint_pattern): Additional attributes. (rint_rm): Ditto. * config/riscv/riscv.md: New attributes. gcc/testsuite/ChangeLog: Kevin Lee * gcc.target/riscv/lfloor-lceil.c: New test. --- gcc/config/riscv/iterators.md | 8 +- gcc/config/riscv/riscv.md | 3 + gcc/testsuite/gcc.target/riscv/lfloor-lceil.c | 79 +++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/lfloor-lceil.c diff --git a/gcc/config/riscv/iterators.md b/gcc/config/riscv/iterators.md index 50380ecfac9..3dd705eaf81 100644 --- a/gcc/config/riscv/iterators.md +++ b/gcc/config/riscv/iterators.md @@ -233,9 +233,11 @@ (define_code_attr bitmanip_insn [(smin "min") ;; ------------------------------------------------------------------- ;; Iterator and attributes for floating-point rounding instructions. -(define_int_iterator RINT [UNSPEC_LRINT UNSPEC_LROUND]) -(define_int_attr rint_pattern [(UNSPEC_LRINT "rint") (UNSPEC_LROUND "round")]) -(define_int_attr rint_rm [(UNSPEC_LRINT "dyn") (UNSPEC_LROUND "rmm")]) +(define_int_iterator RINT [UNSPEC_LRINT UNSPEC_LROUND UNSPEC_LCEIL UNSPEC_LFLOOR]) +(define_int_attr rint_pattern [(UNSPEC_LRINT "rint") (UNSPEC_LROUND "round") + (UNSPEC_LCEIL "ceil") (UNSPEC_LFLOOR "floor")]) +(define_int_attr rint_rm [(UNSPEC_LRINT "dyn") (UNSPEC_LROUND "rmm") + (UNSPEC_LCEIL "rup") (UNSPEC_LFLOOR "rdn")]) ;; Iterator and attributes for quiet comparisons. (define_int_iterator QUIET_COMPARISON [UNSPEC_FLT_QUIET UNSPEC_FLE_QUIET]) diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 798f7370a08..07e72af8950 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -60,6 +60,9 @@ (define_c_enum "unspec" [ UNSPEC_FMIN UNSPEC_FMAX + UNSPEC_LCEIL + UNSPEC_LFLOOR + ;; Stack tie UNSPEC_TIE ]) diff --git a/gcc/testsuite/gcc.target/riscv/lfloor-lceil.c b/gcc/testsuite/gcc.target/riscv/lfloor-lceil.c new file mode 100644 index 00000000000..4715de746fb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/lfloor-lceil.c @@ -0,0 +1,79 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ + +int +ceil1(float i) +{ + return __builtin_lceil(i); +} + +long +ceil2(float i) +{ + return __builtin_lceil(i); +} + +long long +ceil3(float i) +{ + return __builtin_lceil(i); +} + +int +ceil4(double i) +{ + return __builtin_lceil(i); +} + +long +ceil5(double i) +{ + return __builtin_lceil(i); +} + +long long +ceil6(double i) +{ + return __builtin_lceil(i); +} + +int +floor1(float i) +{ + return __builtin_lfloor(i); +} + +long +floor2(float i) +{ + return __builtin_lfloor(i); +} + +long long +floor3(float i) +{ + return __builtin_lfloor(i); +} + +int +floor4(double i) +{ + return __builtin_lfloor(i); +} + +long +floor5(double i) +{ + return __builtin_lfloor(i); +} + +long long +floor6(double i) +{ + return __builtin_lfloor(i); +} + +/* { dg-final { scan-assembler-times "fcvt.l.s" 6 } } */ +/* { dg-final { scan-assembler-times "fcvt.l.d" 6 } } */ +/* { dg-final { scan-assembler-not "call" } } */