From patchwork Mon Nov 6 14:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 162028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2687486vqu; Mon, 6 Nov 2023 06:17:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkwywSG00bOB/O7iTJtyeZ1MiyNA3wXWEwH5J2UgCrCYuIe30zIqY8Ch0Ww6fFzGSpKNb2 X-Received: by 2002:a05:622a:210:b0:417:8eb5:2780 with SMTP id b16-20020a05622a021000b004178eb52780mr38501683qtx.18.1699280220347; Mon, 06 Nov 2023 06:17:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699280220; cv=pass; d=google.com; s=arc-20160816; b=S8XI7s9BlIQIXAmS5Za0GS0CLR0YmTSF2+oJwpIrJHk2hToEIBs8NiKr2iQkoFlQXB aw7KHvQ5zF+UmDENdeWZ3hhASVQpoJaZPbHDSqEgcn/EdYhdQ61rtJcWgsecdhh/KoEI X8sg/kH4YU7hK8ETo9vYa48PiisEaOQS9WF0lt4x5bV/qke8/W6u3tdnzY3UIE7zC27a Vg9HwX6XUGSrIl91s6A/wYPRFJjVDD3HSXCiqU7t7642xt3dk+CvNVd+hzTgvuwJUbao F/+qOZbgkdx4Et62CK+6ic08K8ib0TGfKUpWBSurWmYXtLffrY7/h7VNbCjIkz3FG6VN fm/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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 :arc-filter:dmarc-filter:delivered-to; bh=kOkdLSG2YBdQ48diM2JyxKKuJkvsdc6Nyy+rnZlY7PU=; fh=yqBQmCEeFYB2Wjmf8l8QkV/dOy5iKwSEx/iU/FYQjxU=; b=PyVgnFLEnw9NrOOyRg8Qoi2RKNrSg4S0pME/5XZKkg52hwv8j8ZBbtCMnNM6OE0OBq vFSPkhVNG3tIUXSXTCU6Z1LVFX74pvOz+Jy7BjxoTXivNx44eZWTYojDo9GXaeAnh6nM WYQzmibGTMQm0qFexGi4Huiz+n+kMlQJe4HycVDNKZOEC2ZqrurNp7N0Eqhvroz2yGS7 fntFWvnzvIpQ6/Upo2/78HrkEFDFcR3xB98Gv9H2svWmYLBOgBUBnk6f70i7DRdOwXIf GG+gC3SUB9/GHuDhH8YQveicIXnfiUUHJG7ZLpKCCaWZl5ppHEi2DoMH9fzXyhai2uN8 Blow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HitCnJ5Z; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l13-20020a05622a050d00b00418076d0a1esi5551383qtx.792.2023.11.06.06.17.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:17:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HitCnJ5Z; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A8473858C36 for ; Mon, 6 Nov 2023 14:17:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id E16483858C20 for ; Mon, 6 Nov 2023 14:16:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E16483858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E16483858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.55.52.120 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699280194; cv=none; b=OreVFuwZDA2NCVQkqUvVm9HGgQAZ5i48q4gcvDI0lW8XIKvkgOEeZGx2KSe9rmj4c3vuSlzm2Z9e1khPJJj3o/RYPrypilKowT74idsBaLlk+pR5Xt1TGmF3HGaXx28H6Ks+tCxm8ajnG2N9M/k40ofxHtRdDqqw7MXN4b21v5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699280194; c=relaxed/simple; bh=PEQxJUJKDBsNvfuPJzE/GjsIX0YBAUlDv9Pj/mp0ZKg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ECTT49ZmXukTzY99dgaGI0MsnSZDRPeBi2eXPvQ+qYHbutNVWw+UZbO3+yKbkT1/VHC2T/Du090PfNcwR6HEcg+GTYbeqy60wIXX8X6Oa3PMxSsa9T/RrNThHUY4iStQvYOBkHBRrFKco/1P471yKRFvGi6T/nkdA5mcTIlW0Zc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699280189; x=1730816189; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PEQxJUJKDBsNvfuPJzE/GjsIX0YBAUlDv9Pj/mp0ZKg=; b=HitCnJ5ZJnqRqQBKwYJUaTWrLZR5i2AIMT/q6gLaM7Zw4EI+4h5Uf1z7 qn/UUfhNTBs1eDNLZ9QiKWbtysBZYVVSzKOvZzXWsskbo9YRq0vOmhZTL iseDVkSKvBEPDpGS3q+AKplO829dxRJbkCNYpnSaNE9McNUZHaSwLpb4a SQyvi/Sy61Y+Bgn/yT7OmX/8bSORmP6xBuO31DrD8NcV/vglX6uh3idAE 7Z2oyMQAYEhqoPjn+IS/wLEFCtFyLj6lCtp42PtvQCi1HOrt5TQNQSM6C 0rhoHIpWHmO1xSwLVi4S8EdvMnZf0KPOhN+2ZL660rd2TFI4KnE2nMuQW w==; X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="388160986" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="388160986" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 06:16:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="3631773" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by fmviesa002.fm.intel.com with ESMTP; 06 Nov 2023 06:16:25 -0800 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail02.sh.intel.com (Postfix) with ESMTP id C4DDC1005692; Mon, 6 Nov 2023 22:16:24 +0800 (CST) From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, pan2.li@intel.com, yanzhang.wang@intel.com, kito.cheng@gmail.com Subject: [PATCH v1] RISC-V: Support FP round to i/l/ll diff size autovec Date: Mon, 6 Nov 2023 22:16:23 +0800 Message-Id: <20231106141623.3076456-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781824456643351490 X-GMAIL-MSGID: 1781824456643351490 From: Pan Li This patch would like to support the FP below API auto vectorization with different type size +----------+-----------+----------+ | API | RV64 | RV32 | +----------+-----------+----------+ | iround | DF => SI | DF => SI | | iroundf | - | - | | lround | - | DF => SI | | lroundf | SF => DI | - | | llround | - | - | | llroundf | SF => DI | SF => DI | +----------+-----------+----------+ Given below code: void test_lroundf (long *out, float *in, unsigned count) { for (unsigned i = 0; i < count; i++) out[i] = __builtin_lroundf (in[i]); } Before this patch: .L3: flw fa5,0(a1) addi a1,a1,4 addi a0,a0,8 fcvt.l.s a5,fa5,rmm sd a5,-8(a0) bne a4,a1,.L3 After this patch: fsrmi 4 // RMM rounding mode vsetivli zero,16,e32,m4,ta,ma .L4: vle32.v v4,0(a5) addi a5,a5,64 vfwcvt.x.f.v v8,v4 vse64.v v8,0(a4) addi a4,a4,128 bne a3,a5,.L4 andi a5,a2,15 andi a4,a2,-16 beq a5,zero,.L16 Unfortunately, the HF mode is not include due to it requires additional middle-end support from internal-fun.def. gcc/ChangeLog: * config/riscv/autovec.md: Remove the size check of lround. * config/riscv/riscv-v.cc (expand_vec_lround): Leverage emit_vec_rounding_to_integer for round. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-iround-1.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-iround-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li Signed-off-by: Pan Li > --- gcc/config/riscv/autovec.md | 6 +- gcc/config/riscv/riscv-v.cc | 8 +- .../riscv/rvv/autovec/unop/math-iround-1.c | 18 ++++ .../rvv/autovec/unop/math-iround-run-1.c | 83 ++++++++++++++++++ .../riscv/rvv/autovec/unop/math-llroundf-0.c | 19 +++++ .../rvv/autovec/unop/math-llroundf-run-0.c | 84 +++++++++++++++++++ .../rvv/autovec/unop/math-lround-rv32-0.c | 18 ++++ .../rvv/autovec/unop/math-lround-rv32-run-0.c | 83 ++++++++++++++++++ .../rvv/autovec/unop/math-lroundf-rv64-0.c | 18 ++++ .../autovec/unop/math-lroundf-rv64-run-0.c | 84 +++++++++++++++++++ .../riscv/rvv/autovec/vls/math-iround-1.c | 27 ++++++ .../riscv/rvv/autovec/vls/math-llroundf-0.c | 27 ++++++ .../rvv/autovec/vls/math-lround-rv32-0.c | 27 ++++++ .../rvv/autovec/vls/math-lroundf-rv64-0.c | 27 ++++++ 14 files changed, 520 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iround-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index f1f0523d1de..d1804d82552 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -2420,8 +2420,7 @@ (define_expand "lrint2" (define_expand "lround2" [(match_operand: 0 "register_operand") (match_operand:V_VLS_F_CONVERT_SI 1 "register_operand")] - "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math - && known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (mode))" + "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math" { riscv_vector::expand_vec_lround (operands[0], operands[1], mode, mode); DONE; @@ -2431,8 +2430,7 @@ (define_expand "lround2" (define_expand "lround2" [(match_operand: 0 "register_operand") (match_operand:V_VLS_F_CONVERT_DI 1 "register_operand")] - "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math - && known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (mode))" + "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math" { riscv_vector::expand_vec_lround (operands[0], operands[1], mode, mode); DONE; diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 52eb2aca279..a86741e5a08 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -4167,12 +4167,10 @@ expand_vec_lrint (rtx op_0, rtx op_1, machine_mode vec_fp_mode, void expand_vec_lround (rtx op_0, rtx op_1, machine_mode vec_fp_mode, - machine_mode vec_long_mode) + machine_mode vec_int_mode) { - gcc_assert (known_eq (GET_MODE_SIZE (vec_fp_mode), - GET_MODE_SIZE (vec_long_mode))); - - emit_vec_cvt_x_f (op_0, op_1, UNARY_OP_FRM_RMM, vec_fp_mode); + emit_vec_rounding_to_integer (op_0, op_1, vec_fp_mode, vec_int_mode, + UNARY_OP_FRM_RMM); } void diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-1.c new file mode 100644 index 00000000000..dea438bf5c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "test-math.h" + +/* +** test_double_int___builtin_iround: +** frrm\s+[atx][0-9]+ +** ... +** fsrmi\s+4 +** ... +** vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +** fsrm\s+[atx][0-9]+ +** ret +*/ +TEST_UNARY_CALL_CVT (double, int, __builtin_iround) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c new file mode 100644 index 00000000000..c68207f038c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c @@ -0,0 +1,83 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +double in[ARRAY_SIZE]; +int out[ARRAY_SIZE]; +int ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (double, int, __builtin_iround) +TEST_ASSERT (int) + +TEST_INIT_CVT (double, 0.0, int, __builtin_iround (-0.0), 1) +TEST_INIT_CVT (double, -0.0, int, __builtin_iround (-0.0), 2) +TEST_INIT_CVT (double, 1.2, int, __builtin_iround (1.2), 3) +TEST_INIT_CVT (double, -1.2, int, __builtin_iround (-1.2), 4) +TEST_INIT_CVT (double, 1.5, int, __builtin_iround (1.5), 5) +TEST_INIT_CVT (double, -1.5, int, __builtin_iround (-1.5), 6) +TEST_INIT_CVT (double, 1.8, int, __builtin_iround (1.8), 7) +TEST_INIT_CVT (double, -1.8, int, __builtin_iround (-1.8), 8) +TEST_INIT_CVT (double, 0.2, int, __builtin_iround (0.2), 9) +TEST_INIT_CVT (double, -0.2, int, __builtin_iround (-0.2), 10) +TEST_INIT_CVT (double, 0.5, int, __builtin_iround (0.5), 11) +TEST_INIT_CVT (double, -0.5, int, __builtin_iround (-0.5), 12) +TEST_INIT_CVT (double, 0.8, int, __builtin_iround (0.8), 13) +TEST_INIT_CVT (double, -0.8, int, __builtin_iround (-0.8), 14) +TEST_INIT_CVT (double, 4.0, int, __builtin_iround (4.0), 15) +TEST_INIT_CVT (double, -4.0, int, __builtin_iround (-4.0), 16) +TEST_INIT_CVT (double, 4503599627370495.5, int, __builtin_iround (4503599627370495.5), 17) +TEST_INIT_CVT (double, 4503599627370497.0, int, __builtin_iround (4503599627370497.0), 18) +TEST_INIT_CVT (double, -4503599627370495.5, int, __builtin_iround (-4503599627370495.5), 19) +TEST_INIT_CVT (double, -4503599627370496.0, int, __builtin_iround (-4503599627370496.0), 20) +TEST_INIT_CVT (double, 2147483647.0, int, __builtin_iround (2147483647.0), 21) +TEST_INIT_CVT (double, -2147483648.0, int, __builtin_iround (-2147483648.0), 22) +TEST_INIT_CVT (double, 2147483647.0000002384185791, int, __builtin_iround (2147483647.0000002384185791), 23) +TEST_INIT_CVT (double, -2147483648.0000004768371582, int, __builtin_iround (-2147483648.0000004768371582), 24) +TEST_INIT_CVT (double, 9223372036854774784.0, int, __builtin_iround (9223372036854774784.0), 25) +TEST_INIT_CVT (double, 9223372036854775808.0, int, 0x7fffffff, 26) +TEST_INIT_CVT (double, -9223372036854775808.0, int, __builtin_iround (-9223372036854775808.0), 27) +TEST_INIT_CVT (double, -9223372036854777856.0, int, 0x80000000, 28) +TEST_INIT_CVT (double, __builtin_inf (), int, __builtin_iround (__builtin_inf ()), 29) +TEST_INIT_CVT (double, -__builtin_inf (), int, __builtin_iround (-__builtin_inf ()), 30) +TEST_INIT_CVT (double, __builtin_nan (""), int, 0x7fffffff, 31) + +int +main () +{ + RUN_TEST_CVT (double, int, 1, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 2, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 3, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 4, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 5, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 6, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 7, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 8, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 9, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 10, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 11, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 12, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 13, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 14, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 15, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 16, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 17, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 18, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 19, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 20, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 21, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 22, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 23, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 24, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 25, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 26, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 27, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 28, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 29, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 30, __builtin_iround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, int, 31, __builtin_iround, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c new file mode 100644 index 00000000000..61e3278672d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include +#include "test-math.h" + +/* +** test_float_int64_t___builtin_llroundf: +** frrm\s+[atx][0-9]+ +** ... +** fsrmi\s+4 +** ... +** vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+ +** ... +** fsrm\s+[atx][0-9]+ +** ret +*/ +TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llroundf) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c new file mode 100644 index 00000000000..2b20ccefa40 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c @@ -0,0 +1,84 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +int64_t out[ARRAY_SIZE]; +int64_t ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llroundf) +TEST_ASSERT (int64_t) + +TEST_INIT_CVT (float, 0.0, int64_t, __builtin_llroundf (-0.0), 1) +TEST_INIT_CVT (float, -0.0, int64_t, __builtin_llroundf (-0.0), 2) +TEST_INIT_CVT (float, 1.2, int64_t, __builtin_llroundf (1.2), 3) +TEST_INIT_CVT (float, -1.2, int64_t, __builtin_llroundf (-1.2), 4) +TEST_INIT_CVT (float, 1.5, int64_t, __builtin_llroundf (1.5), 5) +TEST_INIT_CVT (float, -1.5, int64_t, __builtin_llroundf (-1.5), 6) +TEST_INIT_CVT (float, 1.8, int64_t, __builtin_llroundf (1.8), 7) +TEST_INIT_CVT (float, -1.8, int64_t, __builtin_llroundf (-1.8), 8) +TEST_INIT_CVT (float, 0.2, int64_t, __builtin_llroundf (0.2), 9) +TEST_INIT_CVT (float, -0.2, int64_t, __builtin_llroundf (-0.2), 10) +TEST_INIT_CVT (float, 0.5, int64_t, __builtin_llroundf (0.5), 11) +TEST_INIT_CVT (float, -0.5, int64_t, __builtin_llroundf (-0.5), 12) +TEST_INIT_CVT (float, 0.8, int64_t, __builtin_llroundf (0.8), 13) +TEST_INIT_CVT (float, -0.8, int64_t, __builtin_llroundf (-0.8), 14) +TEST_INIT_CVT (float, 4.0, int64_t, __builtin_llroundf (4.0), 15) +TEST_INIT_CVT (float, -4.0, int64_t, __builtin_llroundf (-4.0), 16) +TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_llroundf (8388607.5), 17) +TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_llroundf (8388609.0), 18) +TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_llroundf (-8388607.5), 19) +TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_llroundf (-8388609.0), 20) +TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_llroundf (2147483520.0), 21) +TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_llroundf (2147483648.0), 22) +TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_llroundf (-2147483648.0), 23) +TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_llroundf (-2147483904.0), 24) +TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_llroundf (9223371487098961920.0), 25) +TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26) +TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_llroundf (-9223372036854775808.0), 27) +TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28) +TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_llroundf (__builtin_inf ()), 29) +TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_llroundf (-__builtin_inf ()), 30) +TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31) + +int64_t +main () +{ + RUN_TEST_CVT (float, int64_t, 1, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 2, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 3, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 4, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 5, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 6, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 7, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 8, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 9, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 10, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 11, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 12, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 13, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 14, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 15, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 16, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 17, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 18, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 19, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 20, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 21, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 22, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 23, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 24, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 25, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 26, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 27, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 28, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 29, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 30, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 31, __builtin_llroundf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c new file mode 100644 index 00000000000..c632210441f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32d -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "test-math.h" + +/* +** test_double_int___builtin_lround: +** frrm\s+[atx][0-9]+ +** ... +** fsrmi\s+4 +** ... +** vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +** fsrm\s+[atx][0-9]+ +** ret +*/ +TEST_UNARY_CALL_CVT (double, int, __builtin_lround) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c new file mode 100644 index 00000000000..f9e840d6de6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c @@ -0,0 +1,83 @@ +/* { dg-do run { target { riscv_v && rv32 } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +double in[ARRAY_SIZE]; +long out[ARRAY_SIZE]; +long ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (double, long, __builtin_lround) +TEST_ASSERT (long) + +TEST_INIT_CVT (double, 0.0, long, __builtin_lround (-0.0), 1) +TEST_INIT_CVT (double, -0.0, long, __builtin_lround (-0.0), 2) +TEST_INIT_CVT (double, 1.2, long, __builtin_lround (1.2), 3) +TEST_INIT_CVT (double, -1.2, long, __builtin_lround (-1.2), 4) +TEST_INIT_CVT (double, 1.5, long, __builtin_lround (1.5), 5) +TEST_INIT_CVT (double, -1.5, long, __builtin_lround (-1.5), 6) +TEST_INIT_CVT (double, 1.8, long, __builtin_lround (1.8), 7) +TEST_INIT_CVT (double, -1.8, long, __builtin_lround (-1.8), 8) +TEST_INIT_CVT (double, 0.2, long, __builtin_lround (0.2), 9) +TEST_INIT_CVT (double, -0.2, long, __builtin_lround (-0.2), 10) +TEST_INIT_CVT (double, 0.5, long, __builtin_lround (0.5), 11) +TEST_INIT_CVT (double, -0.5, long, __builtin_lround (-0.5), 12) +TEST_INIT_CVT (double, 0.8, long, __builtin_lround (0.8), 13) +TEST_INIT_CVT (double, -0.8, long, __builtin_lround (-0.8), 14) +TEST_INIT_CVT (double, 4.0, long, __builtin_lround (4.0), 15) +TEST_INIT_CVT (double, -4.0, long, __builtin_lround (-4.0), 16) +TEST_INIT_CVT (double, 4503599627370495.5, long, __builtin_lround (4503599627370495.5), 17) +TEST_INIT_CVT (double, 4503599627370497.0, long, __builtin_lround (4503599627370497.0), 18) +TEST_INIT_CVT (double, -4503599627370495.5, long, __builtin_lround (-4503599627370495.5), 19) +TEST_INIT_CVT (double, -4503599627370496.0, long, __builtin_lround (-4503599627370496.0), 20) +TEST_INIT_CVT (double, 2147483647.0, long, __builtin_lround (2147483647.0), 21) +TEST_INIT_CVT (double, -2147483648.0, long, __builtin_lround (-2147483648.0), 22) +TEST_INIT_CVT (double, 2147483647.0000002384185791, long, __builtin_lround (2147483647.0000002384185791), 23) +TEST_INIT_CVT (double, -2147483648.0000004768371582, long, __builtin_lround (-2147483648.0000004768371582), 24) +TEST_INIT_CVT (double, 9223372036854774784.0, long, __builtin_lround (9223372036854774784.0), 25) +TEST_INIT_CVT (double, 9223372036854775808.0, long, 0x7fffffff, 26) +TEST_INIT_CVT (double, -9223372036854775808.0, long, __builtin_lround (-9223372036854775808.0), 27) +TEST_INIT_CVT (double, -9223372036854777856.0, long, 0x80000000, 28) +TEST_INIT_CVT (double, __builtin_inf (), long, __builtin_lround (__builtin_inf ()), 29) +TEST_INIT_CVT (double, -__builtin_inf (), long, __builtin_lround (-__builtin_inf ()), 30) +TEST_INIT_CVT (double, __builtin_nan (""), long, 0x7fffffff, 31) + +long +main () +{ + RUN_TEST_CVT (double, long, 1, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 2, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 3, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 4, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 5, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 6, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 7, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 8, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 9, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 10, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 11, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 12, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 13, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 14, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 15, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 16, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 17, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 18, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 19, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 20, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 21, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 22, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 23, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 24, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 25, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 26, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 27, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 28, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 29, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 30, __builtin_lround, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (double, long, 31, __builtin_lround, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c new file mode 100644 index 00000000000..64dd19752e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "test-math.h" + +/* +** test_float_long___builtin_lroundf: +** frrm\s+[atx][0-9]+ +** ... +** fsrmi\s+4 +** ... +** vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+ +** ... +** fsrm\s+[atx][0-9]+ +** ret +*/ +TEST_UNARY_CALL_CVT (float, long, __builtin_lroundf) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c new file mode 100644 index 00000000000..0295373bd52 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c @@ -0,0 +1,84 @@ +/* { dg-do run { target { riscv_v && rv64 } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +int64_t out[ARRAY_SIZE]; +int64_t ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, int64_t, __builtin_lroundf) +TEST_ASSERT (int64_t) + +TEST_INIT_CVT (float, 0.0, int64_t, __builtin_lroundf (-0.0), 1) +TEST_INIT_CVT (float, -0.0, int64_t, __builtin_lroundf (-0.0), 2) +TEST_INIT_CVT (float, 1.2, int64_t, __builtin_lroundf (1.2), 3) +TEST_INIT_CVT (float, -1.2, int64_t, __builtin_lroundf (-1.2), 4) +TEST_INIT_CVT (float, 1.5, int64_t, __builtin_lroundf (1.5), 5) +TEST_INIT_CVT (float, -1.5, int64_t, __builtin_lroundf (-1.5), 6) +TEST_INIT_CVT (float, 1.8, int64_t, __builtin_lroundf (1.8), 7) +TEST_INIT_CVT (float, -1.8, int64_t, __builtin_lroundf (-1.8), 8) +TEST_INIT_CVT (float, 0.2, int64_t, __builtin_lroundf (0.2), 9) +TEST_INIT_CVT (float, -0.2, int64_t, __builtin_lroundf (-0.2), 10) +TEST_INIT_CVT (float, 0.5, int64_t, __builtin_lroundf (0.5), 11) +TEST_INIT_CVT (float, -0.5, int64_t, __builtin_lroundf (-0.5), 12) +TEST_INIT_CVT (float, 0.8, int64_t, __builtin_lroundf (0.8), 13) +TEST_INIT_CVT (float, -0.8, int64_t, __builtin_lroundf (-0.8), 14) +TEST_INIT_CVT (float, 4.0, int64_t, __builtin_lroundf (4.0), 15) +TEST_INIT_CVT (float, -4.0, int64_t, __builtin_lroundf (-4.0), 16) +TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_lroundf (8388607.5), 17) +TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_lroundf (8388609.0), 18) +TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_lroundf (-8388607.5), 19) +TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_lroundf (-8388609.0), 20) +TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_lroundf (2147483520.0), 21) +TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_lroundf (2147483648.0), 22) +TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_lroundf (-2147483648.0), 23) +TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_lroundf (-2147483904.0), 24) +TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_lroundf (9223371487098961920.0), 25) +TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26) +TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_lroundf (-9223372036854775808.0), 27) +TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28) +TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_lroundf (__builtin_inf ()), 29) +TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_lroundf (-__builtin_inf ()), 30) +TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31) + +int64_t +main () +{ + RUN_TEST_CVT (float, int64_t, 1, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 2, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 3, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 4, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 5, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 6, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 7, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 8, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 9, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 10, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 11, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 12, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 13, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 14, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 15, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 16, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 17, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 18, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 19, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 20, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 21, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 22, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 23, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 24, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 25, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 26, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 27, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 28, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 29, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 30, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int64_t, 31, __builtin_lroundf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iround-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iround-1.c new file mode 100644 index 00000000000..bad232d729d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iround-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (iround, 1, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 2, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 4, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 8, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 16, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 32, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 64, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 128, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 256, double, int, __builtin_iround) +DEF_OP_V_CVT (iround, 512, double, int, __builtin_iround) + +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */ +/* { dg-final { scan-assembler-times {vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+} 9 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c new file mode 100644 index 00000000000..d3993fcfc4f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (llroundf, 1, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 2, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 4, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 8, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 16, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 32, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 64, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 128, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 256, float, int64_t, __builtin_llroundf) +DEF_OP_V_CVT (llroundf, 512, float, int64_t, __builtin_llroundf) + +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */ +/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c new file mode 100644 index 00000000000..f52685409c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv_zvl4096b -mabi=ilp32d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (lround, 1, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 2, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 4, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 8, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 16, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 32, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 64, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 128, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 256, double, int, __builtin_lround) +DEF_OP_V_CVT (lround, 512, double, int, __builtin_lround) + +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */ +/* { dg-final { scan-assembler-times {vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+} 9 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c new file mode 100644 index 00000000000..2c6515aa965 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (lroundf, 1, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 2, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 4, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 8, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 16, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 32, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 64, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 128, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 256, float, long, __builtin_lroundf) +DEF_OP_V_CVT (lroundf, 512, float, long, __builtin_lroundf) + +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */ +/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */