From patchwork Sun Nov 5 09:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 161624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2039513vqu; Sun, 5 Nov 2023 01:30:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9E+j68ENZ3Ee+nOoga6YttJ5Q8ygZg71Jx5p8ADrXjoVMVT6fAezqPtXHF6nKHOp+qrxj X-Received: by 2002:ad4:5f4e:0:b0:66d:6705:5c50 with SMTP id p14-20020ad45f4e000000b0066d67055c50mr31862469qvg.44.1699176647513; Sun, 05 Nov 2023 01:30:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699176647; cv=pass; d=google.com; s=arc-20160816; b=flQ8DJLkDQkO+5q8Sfcni5lktZpP2eH+qbG5QgKPz3apth4feExzyfkibsk9Fuey5T DATXNA21gUvuKvwo8ffNzF2DPuL31DOr4JA+o4Zc+y/zOBd/cr7TPYkoN4P5cFY9Z/DJ 4j11OvGk+0vU73JYkn7uJ6+J2MHuwuqKij8iG8TFesTiGKReqQ8duajHvYuIBAJuQMeb zsiKHRCsW+FZEpI6LKd1rzQu0gqih7auxrLzWXCRyl8avR34abYscqr0vdApoRxqZwN3 XiHfhcJJWLvJepL6owvaaMoo2wVXCgOmj/HKjJljlvXwTPsMnfBff+F5Ni6JD3bP2Heb +MfA== 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=z4DVN99DHp5dHedQKbFCGJ47Lnf3zBICqHMpi4NSNN8=; fh=yqBQmCEeFYB2Wjmf8l8QkV/dOy5iKwSEx/iU/FYQjxU=; b=FvF5QmBunftieBVrl3NJM2ANh8KoF9W6J3CMAoeG51r4T6sBLXDKbzRtv0x0N8gXjx Xs/tYFlIlbSSSoxUhSe2m6qFDbQV/JiOBm4+0RNu/AVvDMD47uHpM2FnL9WG5VU/htvE 8qVQGT4gkPvAeI+q4mSMcsF8IIlwFZZrWMVlVHlAoUhEiCIFZzd9QY3HtU1qYuoMCejg 8nJdobPgHQ2cxp9JT7ikV0l6Bv2QaYahRfH/fN+3qLsROddtbULE1altlT6QuUkjJHXa wX2UXHSmbzB5pNNo/dKaV+bPasLNGwM2VeJZ9yuRrJzbEEYEEBH3ED+RWjoIQqUcfBW0 UWqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H07jiJ9k; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id cx9-20020a056214188900b0066d20730d39si3991042qvb.356.2023.11.05.01.30.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 01:30:47 -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=@intel.com header.s=Intel header.b=H07jiJ9k; arc=pass (i=1); 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"; 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 3C7E13858409 for ; Sun, 5 Nov 2023 09:30:47 +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 [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id BB3153858D3C for ; Sun, 5 Nov 2023 09:30:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB3153858D3C 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 BB3153858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.65 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699176623; cv=none; b=jcagRR+Qhp0A23EuwOI3LuGFh6o+dAiEdr8o/OYU4STXaOwC3Wx22gyYEm42GzcIS7IiVPTPPSzjtlCxPWWcqyH/2Rzqi1tU/fN0CWIKz4gqWc7SF/uxvpQjmR4nxvQtB5yTd3zjwy35GnFtSHEFi2IPUJpzkoVg6bgf1xiAYF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699176623; c=relaxed/simple; bh=TDmWLBKlLfLEj/S6Qo8j7cwJeaFONVxOI+uRsphkt+E=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=AqEwCmJDqXIhbey320ld0eCtAen47j9Eg9btmVnYu9QctySLJLCCMcsf64dz94aIZ/AjWm2fyV3r96g7rT+yT7q+LCkKk3BjNlMsbp2viFxB/9XNpmGEfcGw0kEtq8j21jppMJOXYnWh3TFfmUjIX6Ew2/xVJgQdD4gnnp7Cl6A= 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=1699176617; x=1730712617; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TDmWLBKlLfLEj/S6Qo8j7cwJeaFONVxOI+uRsphkt+E=; b=H07jiJ9kvjz05E+GUF+jG+h/mJdbacKiv2gXhlVeT4rJ4xxEpDCdRx/+ jx/QJYDhirWX6IDhNS/xDBjqyUoO4KuZVBRo24PKeQYqClNm70keJgXwq WQdCMqpcJynrKEZtDzXGdpOM7bZ/uYXV1uySVYDMJ2/mIEfDXfQjCdqYs z7gQTPCOzM4y57+i/mFOIZxpHTJ6/qikK8Pu2rU+WO8JnIIjM8TZhgUWX ulzbjCak+zbk+U3jWrr/dCbRIpRdPEq8RnOLjNDxHPqFibpW2+K6+X5zY Ii1Pcq7gP5mv3yMTjDCgaWAbfunn16GP75vOhEK5C2vgOrTnFlLFIsb7B w==; X-IronPort-AV: E=McAfee;i="6600,9927,10884"; a="393024919" X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="393024919" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 01:30:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10884"; a="762031330" X-IronPort-AV: E=Sophos;i="6.03,279,1694761200"; d="scan'208";a="762031330" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by orsmga002.jf.intel.com with ESMTP; 05 Nov 2023 01:30:13 -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 D6FBA100567A; Sun, 5 Nov 2023 17:30:12 +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 rint to i/l/ll diff size autovec Date: Sun, 5 Nov 2023 17:30:11 +0800 Message-Id: <20231105093011.2038618-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 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: 1781715852075008137 X-GMAIL-MSGID: 1781715852075008137 From: Pan Li This patch would like to support the FP below API auto vectorization with different type size +---------+-----------+----------+ | API | RV64 | RV32 | +---------+-----------+----------+ | irint | DF => SI | DF => SI | | irintf | - | - | | lrint | - | DF => SI | | lrintf | SF => DI | - | | llrint | - | - | | llrintf | SF => DI | SF => DI | +---------+-----------+----------+ Given below code: void test_lrintf (long *out, float *in, unsigned count) { for (unsigned i = 0; i < count; i++) out[i] = __builtin_lrintf (in[i]); } Before this patch: test_lrintf: beq a2,zero,.L8 slli a5,a2,32 srli a2,a5,30 add a4,a1,a2 .L3: flw fa5,0(a1) addi a1,a1,4 addi a0,a0,8 fcvt.l.s a5,fa5,dyn sd a5,-8(a0) bne a1,a4,.L3 After this patch: test_lrintf: beq a2,zero,.L8 slli a2,a2,32 srli a2,a2,32 .L3: vsetvli a5,a2,e32,mf2,ta,ma vle32.v v2,0(a1) slli a3,a5,2 slli a4,a5,3 vfwcvt.x.f.v v1,v2 sub a2,a2,a5 vse64.v v1,0(a0) add a1,a1,a3 add a0,a0,a4 bne a2,zero,.L3 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 lrint. * config/riscv/riscv-v.cc (emit_vec_narrow_cvt_x_f): New help emit func impl. (emit_vec_widden_cvt_x_f): New help emit func impl. (emit_vec_rounding_to_integer): New func impl to emit the rounding from FP to integer. (expand_vec_lrint): Leverage emit_vec_rounding_to_integer. * config/riscv/vector.md: Take V_VLSF for vfncvt. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c: * gcc.target/riscv/rvv/autovec/unop/math-irint-1.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-irint-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- gcc/config/riscv/autovec.md | 6 +- gcc/config/riscv/riscv-v.cc | 46 +++++++++- gcc/config/riscv/vector.md | 2 +- .../riscv/rvv/autovec/unop/math-irint-1.c | 13 +++ .../riscv/rvv/autovec/unop/math-irint-run-0.c | 92 +++++++++---------- .../rvv/autovec/unop/math-irintf-run-0.c | 63 +++++++++++++ .../riscv/rvv/autovec/unop/math-llrintf-0.c | 13 +++ .../rvv/autovec/unop/math-llrintf-run-0.c | 63 +++++++++++++ .../rvv/autovec/unop/math-lrint-rv32-0.c | 13 +++ .../rvv/autovec/unop/math-lrint-rv32-run-0.c | 63 +++++++++++++ .../rvv/autovec/unop/math-lrintf-rv64-0.c | 13 +++ .../rvv/autovec/unop/math-lrintf-rv64-run-0.c | 63 +++++++++++++ .../riscv/rvv/autovec/vls/math-irint-1.c | 30 ++++++ .../riscv/rvv/autovec/vls/math-llrintf-0.c | 30 ++++++ .../riscv/rvv/autovec/vls/math-lrint-rv32-0.c | 30 ++++++ .../rvv/autovec/vls/math-lrintf-rv64-0.c | 30 ++++++ 16 files changed, 514 insertions(+), 56 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index cc4c9596bbf..f1f0523d1de 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -2400,8 +2400,7 @@ (define_expand "roundeven2" (define_expand "lrint2" [(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_lrint (operands[0], operands[1], mode, mode); DONE; @@ -2411,8 +2410,7 @@ (define_expand "lrint2" (define_expand "lrint2" [(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_lrint (operands[0], operands[1], mode, mode); DONE; diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index b489ce08775..52eb2aca279 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -3927,6 +3927,26 @@ emit_vec_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, emit_vlmax_insn (icode, type, ops); } +static void +emit_vec_narrow_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, + machine_mode vec_mode) +{ + rtx ops[] = {op_dest, op_src}; + insn_code icode = code_for_pred_narrow_fcvt_x_f (UNSPEC_VFCVT, vec_mode); + + emit_vlmax_insn (icode, type, ops); +} + +static void +emit_vec_widden_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, + machine_mode vec_mode) +{ + rtx ops[] = {op_dest, op_src}; + insn_code icode = code_for_pred_widen_fcvt_x_f (UNSPEC_VFCVT, vec_mode); + + emit_vlmax_insn (icode, type, ops); +} + static void emit_vec_cvt_f_x (rtx op_dest, rtx op_src, rtx mask, insn_type type, machine_mode vec_mode) @@ -4119,14 +4139,30 @@ expand_vec_roundeven (rtx op_0, rtx op_1, machine_mode vec_fp_mode, emit_vec_copysign (op_0, op_0, op_1, vec_fp_mode); } +/* Handling the rounding from floating-point to int/long/long long. */ +static void +emit_vec_rounding_to_integer (rtx op_0, rtx op_1, machine_mode vec_fp_mode, + machine_mode vec_int_mode, insn_type type) +{ + poly_uint16 vec_fp_size = GET_MODE_SIZE (vec_fp_mode); + poly_uint16 vec_int_size = GET_MODE_SIZE (vec_int_mode); + + if (known_eq (vec_fp_size, vec_int_size)) /* SF => SI, DF => DI. */ + emit_vec_cvt_x_f (op_0, op_1, type, vec_fp_mode); + else if (maybe_eq (vec_fp_size, vec_int_size * 2)) /* DF => SI. */ + emit_vec_narrow_cvt_x_f (op_0, op_1, type, vec_fp_mode); + else if (maybe_eq (vec_fp_size * 2, vec_int_size)) /* SF => DI. */ + emit_vec_widden_cvt_x_f (op_0, op_1, type, vec_int_mode); + else /* HF requires additional middle-end support. */ + gcc_unreachable (); +} + void expand_vec_lrint (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_DYN, vec_fp_mode); + emit_vec_rounding_to_integer (op_0, op_1, vec_fp_mode, vec_int_mode, + UNARY_OP_FRM_DYN); } void diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index ce5c5be8e42..88f2ef0566c 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -7661,7 +7661,7 @@ (define_insn "@pred_narrow_fcvt_x_f" (reg:SI VTYPE_REGNUM) (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (unspec: - [(match_operand:VF 3 "register_operand" " 0, 0, 0, 0, vr, vr")] VFCVTS) + [(match_operand:V_VLSF 3 "register_operand" " 0, 0, 0, 0, vr, vr")] VFCVTS) (match_operand: 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))] "TARGET_VECTOR" "vfncvt.x.f.w\t%0,%3%p1" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c new file mode 100644 index 00000000000..0dab456c3ac --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c @@ -0,0 +1,13 @@ +/* { 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_irint: +** ... +** vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +TEST_UNARY_CALL_CVT (double, int, __builtin_irint) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c index 0be38528d0b..43bc0849695 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c @@ -6,58 +6,58 @@ #define ARRAY_SIZE 128 float in[ARRAY_SIZE]; -int out[ARRAY_SIZE]; -int ref[ARRAY_SIZE]; +long out[ARRAY_SIZE]; +long ref[ARRAY_SIZE]; -TEST_UNARY_CALL_CVT (float, int, __builtin_irintf) -TEST_ASSERT (int) +TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf) +TEST_ASSERT (long) -TEST_INIT_CVT (float, 1.2, int, __builtin_irintf (1.2), 1) -TEST_INIT_CVT (float, -1.2, int, __builtin_irintf (-1.2), 2) -TEST_INIT_CVT (float, 0.5, int, __builtin_irintf (0.5), 3) -TEST_INIT_CVT (float, -0.5, int, __builtin_irintf (-0.5), 4) -TEST_INIT_CVT (float, 0.1, int, __builtin_irintf (0.1), 5) -TEST_INIT_CVT (float, -0.1, int, __builtin_irintf (-0.1), 6) -TEST_INIT_CVT (float, 3.0, int, __builtin_irintf (3.0), 7) -TEST_INIT_CVT (float, -3.0, int, __builtin_irintf (-3.0), 8) -TEST_INIT_CVT (float, 8388607.5, int, __builtin_irintf (8388607.5), 9) -TEST_INIT_CVT (float, 8388609.0, int, __builtin_irintf (8388609.0), 10) -TEST_INIT_CVT (float, -8388607.5, int, __builtin_irintf (-8388607.5), 11) -TEST_INIT_CVT (float, -8388609.0, int, __builtin_irintf (-8388609.0), 12) -TEST_INIT_CVT (float, 0.0, int, __builtin_irintf (-0.0), 13) -TEST_INIT_CVT (float, -0.0, int, __builtin_irintf (-0.0), 14) -TEST_INIT_CVT (float, 2147483520.0, int, __builtin_irintf (2147483520.0), 15) -TEST_INIT_CVT (float, 2147483648.0, int, __builtin_irintf (2147483648.0), 16) -TEST_INIT_CVT (float, -2147483648.0, int, __builtin_irintf (-2147483648.0), 17) -TEST_INIT_CVT (float, -2147483904.0, int, __builtin_irintf (-2147483904.0), 18) -TEST_INIT_CVT (float, __builtin_inf (), int, __builtin_irintf (__builtin_inff ()), 19) -TEST_INIT_CVT (float, -__builtin_inf (), int, __builtin_irintf (-__builtin_inff ()), 20) -TEST_INIT_CVT (float, __builtin_nanf (""), int, 0x7fffffff, 21) +TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1) +TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3) +TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5) +TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7) +TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8) +TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf (4503599627370495.5), 9) +TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf (4503599627370497.0), 10) +TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf (-4503599627370495.5), 11) +TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf (-4503599627370496.0), 12) +TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14) +TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf (9223372036854774784.0), 15) +TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf (9223372036854775808.0), 16) +TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf (-9223372036854775808.0), 17) +TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf (-9223372036854777856.0), 18) +TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf (-__builtin_inf ()), 20) +TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21) int main () { - RUN_TEST_CVT (float, int, 1, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 2, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 3, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 4, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 5, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 6, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 7, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 8, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 9, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 10, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 11, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 12, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 13, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 14, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 15, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 16, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 17, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 18, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 19, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 20, __builtin_irintf, in, out, ref, ARRAY_SIZE); - RUN_TEST_CVT (float, int, 21, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE); return 0; } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c new file mode 100644 index 00000000000..0be38528d0b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c @@ -0,0 +1,63 @@ +/* { 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 + +float in[ARRAY_SIZE]; +int out[ARRAY_SIZE]; +int ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, int, __builtin_irintf) +TEST_ASSERT (int) + +TEST_INIT_CVT (float, 1.2, int, __builtin_irintf (1.2), 1) +TEST_INIT_CVT (float, -1.2, int, __builtin_irintf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, int, __builtin_irintf (0.5), 3) +TEST_INIT_CVT (float, -0.5, int, __builtin_irintf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, int, __builtin_irintf (0.1), 5) +TEST_INIT_CVT (float, -0.1, int, __builtin_irintf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, int, __builtin_irintf (3.0), 7) +TEST_INIT_CVT (float, -3.0, int, __builtin_irintf (-3.0), 8) +TEST_INIT_CVT (float, 8388607.5, int, __builtin_irintf (8388607.5), 9) +TEST_INIT_CVT (float, 8388609.0, int, __builtin_irintf (8388609.0), 10) +TEST_INIT_CVT (float, -8388607.5, int, __builtin_irintf (-8388607.5), 11) +TEST_INIT_CVT (float, -8388609.0, int, __builtin_irintf (-8388609.0), 12) +TEST_INIT_CVT (float, 0.0, int, __builtin_irintf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, int, __builtin_irintf (-0.0), 14) +TEST_INIT_CVT (float, 2147483520.0, int, __builtin_irintf (2147483520.0), 15) +TEST_INIT_CVT (float, 2147483648.0, int, __builtin_irintf (2147483648.0), 16) +TEST_INIT_CVT (float, -2147483648.0, int, __builtin_irintf (-2147483648.0), 17) +TEST_INIT_CVT (float, -2147483904.0, int, __builtin_irintf (-2147483904.0), 18) +TEST_INIT_CVT (float, __builtin_inf (), int, __builtin_irintf (__builtin_inff ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), int, __builtin_irintf (-__builtin_inff ()), 20) +TEST_INIT_CVT (float, __builtin_nanf (""), int, 0x7fffffff, 21) + +int +main () +{ + RUN_TEST_CVT (float, int, 1, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 2, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 3, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 4, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 5, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 6, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 7, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 8, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 9, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 10, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 11, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 12, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 13, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 14, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 15, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 16, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 17, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 18, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 19, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 20, __builtin_irintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 21, __builtin_irintf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c new file mode 100644 index 00000000000..113fffb47ff --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c @@ -0,0 +1,13 @@ +/* { 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_llrintf: +** ... +** vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +TEST_UNARY_CALL_CVT (float, long, __builtin_llrintf) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c new file mode 100644 index 00000000000..43bc0849695 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c @@ -0,0 +1,63 @@ +/* { 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 + +float in[ARRAY_SIZE]; +long out[ARRAY_SIZE]; +long ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf) +TEST_ASSERT (long) + +TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1) +TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3) +TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5) +TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7) +TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8) +TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf (4503599627370495.5), 9) +TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf (4503599627370497.0), 10) +TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf (-4503599627370495.5), 11) +TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf (-4503599627370496.0), 12) +TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14) +TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf (9223372036854774784.0), 15) +TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf (9223372036854775808.0), 16) +TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf (-9223372036854775808.0), 17) +TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf (-9223372036854777856.0), 18) +TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf (-__builtin_inf ()), 20) +TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21) + +int +main () +{ + RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c new file mode 100644 index 00000000000..cac57877876 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c @@ -0,0 +1,13 @@ +/* { 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_long___builtin_lrint: +** ... +** vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +TEST_UNARY_CALL_CVT (double, long, __builtin_lrint) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c new file mode 100644 index 00000000000..c1c8cc32588 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c @@ -0,0 +1,63 @@ +/* { 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 + +float in[ARRAY_SIZE]; +long out[ARRAY_SIZE]; +long ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf) +TEST_ASSERT (long) + +TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1) +TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3) +TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5) +TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7) +TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8) +TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf (4503599627370495.5), 9) +TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf (4503599627370497.0), 10) +TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf (-4503599627370495.5), 11) +TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf (-4503599627370496.0), 12) +TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14) +TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf (9223372036854774784.0), 15) +TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf (9223372036854775808.0), 16) +TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf (-9223372036854775808.0), 17) +TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf (-9223372036854777856.0), 18) +TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf (-__builtin_inf ()), 20) +TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21) + +int +main () +{ + RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c new file mode 100644 index 00000000000..6e09472ebe7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c @@ -0,0 +1,13 @@ +/* { 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_lrintf: +** ... +** vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+ +** ... +*/ +TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c new file mode 100644 index 00000000000..f5a9e01d0e8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c @@ -0,0 +1,63 @@ +/* { dg-do run { target { riscv_v && rv64 } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +long out[ARRAY_SIZE]; +long ref[ARRAY_SIZE]; + +TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf) +TEST_ASSERT (long) + +TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1) +TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3) +TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5) +TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7) +TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8) +TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf (4503599627370495.5), 9) +TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf (4503599627370497.0), 10) +TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf (-4503599627370495.5), 11) +TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf (-4503599627370496.0), 12) +TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14) +TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf (9223372036854774784.0), 15) +TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf (9223372036854775808.0), 16) +TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf (-9223372036854775808.0), 17) +TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf (-9223372036854777856.0), 18) +TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf (-__builtin_inf ()), 20) +TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21) + +int +main () +{ + RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c new file mode 100644 index 00000000000..5447326b997 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (irint, 1, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 2, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 4, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 8, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 16, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 32, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 64, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 128, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 256, double, int, __builtin_irint) +DEF_OP_V_CVT (irint, 512, double, int, __builtin_irint) + +/* { 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-tree-dump-not "1024,1024" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4096,4096" "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-llrintf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c new file mode 100644 index 00000000000..9445f5df60e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (llrintf, 1, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 2, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 4, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 8, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 16, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 32, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 64, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 128, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 256, float, long, __builtin_llrintf) +DEF_OP_V_CVT (llrintf, 512, float, long, __builtin_llrintf) + +/* { 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-tree-dump-not "1024,1024" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4096,4096" "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-lrint-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c new file mode 100644 index 00000000000..61563e47aa0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv_zvfh_zvl4096b -mabi=ilp32d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (lrint, 1, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 2, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 4, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 8, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 16, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 32, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 64, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 128, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 256, double, long, __builtin_lrint) +DEF_OP_V_CVT (lrint, 512, double, long, __builtin_lrint) + +/* { 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-tree-dump-not "1024,1024" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4096,4096" "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-lrintf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c new file mode 100644 index 00000000000..b095ff280ad --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */ + +#include "def.h" + +DEF_OP_V_CVT (lrintf, 1, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 2, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 4, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 8, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 16, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 32, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 64, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 128, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 256, float, long, __builtin_lrintf) +DEF_OP_V_CVT (lrintf, 512, float, long, __builtin_lrintf) + +/* { 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-tree-dump-not "1024,1024" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */ +/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */