From patchwork Fri Oct 13 08:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 1848049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Sj5Quty5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S6KKZ1wlqz1yqZ for ; Fri, 13 Oct 2023 19:24:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE1033857725 for ; Fri, 13 Oct 2023 08:23:59 +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.24]) by sourceware.org (Postfix) with ESMTPS id 94CDA3858C3A for ; Fri, 13 Oct 2023 08:23:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94CDA3858C3A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697185423; x=1728721423; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WM4d412vskXWwSSNOyp/REnbhYfN+wtrwqg7hIX5Hvo=; b=Sj5Quty5k8F2/4CtIBeEVpkOWtFTWRxs5rw57E9emA42mtLck7bAv4JI 9yFVMVyoZJrsXwtbJaUwewvneCGR6YPEnEdgLAK75O5oF6YfsjYYVYoaA UevNM1E3ebznO3yn/46BUiFdRZGC8ImNQJftgF/jt4k7p05+qY7CN5jFD Pnt5PLSVRijiXmIB4pb+ntVF+KigpcqV3NQRpyvpRgZUU1GHaJmMAQ+Eq luv4FYvjj5DBwoCtaNK7ElyCCDIMLm7KgJuRfVuZEB5eU/qo6zDFFgQuf Te51IM310rQs02GOUxc0a84ABTfVCoOO0jMWImoOwFkUf+A1e4x0j2hj6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="387982729" X-IronPort-AV: E=Sophos;i="6.03,221,1694761200"; d="scan'208";a="387982729" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 01:23:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="704551884" X-IronPort-AV: E=Sophos;i="6.03,221,1694761200"; d="scan'208";a="704551884" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga003.jf.intel.com with ESMTP; 13 Oct 2023 01:23:39 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 4251D10056F9; Fri, 13 Oct 2023 16:23:38 +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: Add test for FP ifloor auto vectorization Date: Fri, 13 Oct 2023 16:23:36 +0800 Message-Id: <20231013082336.1845369-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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Pan Li The below FP API are supported already by sharing the same standard name, as well as the machine mode. int ifloor (float); This patch would like to add the test cases for ensuring the correctness. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- .../riscv/rvv/autovec/unop/math-ifloor-0.c | 19 ++++++ .../rvv/autovec/unop/math-ifloor-run-0.c | 63 +++++++++++++++++++ .../riscv/rvv/autovec/vls/math-ifloor-0.c | 30 +++++++++ 3 files changed, 112 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c new file mode 100644 index 00000000000..b9ec415d690 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-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 "test-math.h" + +/* +** test_float_int___builtin_ifloorf: +** frrm\s+[atx][0-9]+ +** ... +** fsrmi\s+2 +** ... +** vsetvli\s+[atx][0-9]+,\s*zero,\s*e32,\s*m1,\s*ta,\s*ma +** vfcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+ +** ... +** fsrm\s+[atx][0-9]+ +** ret +*/ +TEST_UNARY_CALL_CVT (float, int, __builtin_ifloorf) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-0.c new file mode 100644 index 00000000000..8ef4da0ea88 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ifloor-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_ifloorf) +TEST_ASSERT (int) + +TEST_INIT_CVT (float, 1.2, int, __builtin_ifloorf (1.2), 1) +TEST_INIT_CVT (float, -1.2, int, __builtin_ifloorf (-1.2), 2) +TEST_INIT_CVT (float, 0.5, int, __builtin_ifloorf (0.5), 3) +TEST_INIT_CVT (float, -0.5, int, __builtin_ifloorf (-0.5), 4) +TEST_INIT_CVT (float, 0.1, int, __builtin_ifloorf (0.1), 5) +TEST_INIT_CVT (float, -0.1, int, __builtin_ifloorf (-0.1), 6) +TEST_INIT_CVT (float, 3.0, int, __builtin_ifloorf (3.0), 7) +TEST_INIT_CVT (float, -3.0, int, __builtin_ifloorf (-3.0), 8) +TEST_INIT_CVT (float, 8388607.5, int, __builtin_ifloorf (8388607.5), 9) +TEST_INIT_CVT (float, 8388609.0, int, __builtin_ifloorf (8388609.0), 10) +TEST_INIT_CVT (float, -8388607.5, int, __builtin_ifloorf (-8388607.5), 11) +TEST_INIT_CVT (float, -8388609.0, int, __builtin_ifloorf (-8388609.0), 12) +TEST_INIT_CVT (float, 0.0, int, __builtin_ifloorf (-0.0), 13) +TEST_INIT_CVT (float, -0.0, int, __builtin_ifloorf (-0.0), 14) +TEST_INIT_CVT (float, 2147483520.0, int, __builtin_ifloorf (2147483520.0), 15) +TEST_INIT_CVT (float, 2147483648.0, int, 0x7fffffff, 16) +TEST_INIT_CVT (float, -2147483648.0, int, __builtin_ifloorf (-2147483648.0), 17) +TEST_INIT_CVT (float, -2147483904.0, int, 0x80000000, 18) +TEST_INIT_CVT (float, __builtin_inf (), int, __builtin_ifloorf (__builtin_inff ()), 19) +TEST_INIT_CVT (float, -__builtin_inf (), int, __builtin_ifloorf (-__builtin_inff ()), 20) +TEST_INIT_CVT (float, __builtin_nanf (""), int, 0x7fffffff, 21) + +int +main () +{ + RUN_TEST_CVT (float, int, 1, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 2, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 3, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 4, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 5, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 6, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 7, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 8, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 9, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 10, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 11, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 12, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 13, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 14, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 15, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 16, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 17, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 18, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 19, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 20, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + RUN_TEST_CVT (float, int, 21, __builtin_ifloorf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c new file mode 100644 index 00000000000..69eaa11f6d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c @@ -0,0 +1,30 @@ +/* { 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 (ifloorf, 1, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 2, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 4, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 8, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 16, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 32, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 64, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 128, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 256, float, int, __builtin_ifloorf) +DEF_OP_V_CVT (ifloorf, 512, float, int, __builtin_ifloorf) + +/* { 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 {vfcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */