From patchwork Tue Nov 27 16:51:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 202263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 54E422C0087 for ; Wed, 28 Nov 2012 03:52:25 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1354639946; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=Zu/gDGQeB3uqJqx0OWQh i3IDAQU=; b=Ed1gbtSYus0vIOgjk0jCKNXK7VX3ejwEPIAL4Rqaw0SRODqe0gMh U8Kyp69pqagBptS0mdFhdhNInCgijqRJAHRlVS0eLLqT8jW0R867xEO7+dEkTx0l 3AsiB4WB1gT8f3FthKGExnxvpyjjRcCqwOYxtLytN6+FT7OLBqyi8y4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:MIME-Version:X-MC-Unique:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=WgBRQXhiMqE6wQTJgt+24mi7Wy4BW4gFJC/8Z5id5pDhlZk8bS7n5IzJ45Gfcu s2EJA7kC8HMLJqTne5VCEfc5Xx5YQGSLM0mnLLLQ8hhH1ddFCMbRQ2vZdX0yqxRs +H4P3nu7YwGULTHkyjABnmGaNEM69P52VJIB75PKwYlZ8=; Received: (qmail 13350 invoked by alias); 27 Nov 2012 16:52:15 -0000 Received: (qmail 13271 invoked by uid 22791); 27 Nov 2012 16:52:12 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, TW_FC X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Nov 2012 16:51:57 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 27 Nov 2012 16:51:54 +0000 Received: from e106375-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 27 Nov 2012 16:51:53 +0000 From: James Greenhalgh To: gcc-patches@gcc.gnu.org Cc: janisjo@codesourcery.com, mikestump@comcast.net, marcus.shawcroft@arm.com Subject: [Patch AArch64] Add support for vectorizable standard math patterns. Date: Tue, 27 Nov 2012 16:51:39 +0000 Message-Id: <1354035099-30521-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-MC-Unique: 112112716515413101 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, This patch adds support for vectorizing across some of the rounding functions in the C math library to the AArch64 back-end. In particular, we add support for vectorizing across: ceil (), ceilf (), lceil (), floor (), floorf (), lfloor (), round (), roundf (), nearbyint (), nearbyintf (), trunc (), truncf () We add testcases ensuring that each of the expected functions are vectorized. As the i386 and rs6000 backends both ostensibly support these optimisations we add these tests to the generic testsuites, but only wire them up for AArch64. As a target may support any subset of these vectorizations we need a check_effective_target macro for each of them. Because of this change to the generic test code I've CCed Janis Johnson and Mike Stump. Is this patch OK to commit? Thanks, James --- gcc/ 2012-11-27 James Greenhalgh * gcc/config/aarch64/aarch64-builtins.c (aarch64_builtin_vectorized_function): New. * gcc/config/aarch64/aarch64-protos.h (aarch64_builtin_vectorized_function): Declare. * gcc/config/aarch64/aarch64-simd-builtins.def (frintz, frintp): Add. (frintm, frinti, frintx, frinta, fcvtzs, fcvtzu): Likewise. (fcvtas, fcvtau, fcvtps, fcvtpu, fcvtms, fcvtmu): Likewise. * gcc/config/aarch64/aarch64-simd.md (aarch64_frint_): New. (2): Likewise. (aarch64_fcvt): Likewise. (l2): Likewise. * gcc/config/aarch64/aarch64.c (TARGET_VECTORIZE_BUILTINS): Define. (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise. * gcc/config/aarch64/aarch64.md (btrunc2, ceil2, floor2) (round2, rint2, nearbyint2): Consolidate as... (2): ...this. (lceil2, lfloor2) (lround2) (lrint2): Consolidate as... (l2): ... this. * gcc/config/aarch64/iterators.md (fcvt_target): New. (FCVT_TARGET): Likewise. (FRINT): Likewise. (FCVT): Likewise. (frint_pattern): Likewise. (frint_suffix): Likewise. (fcvt_pattern): Likewise. gcc/testsuite/ 2012-11-27 James Greenhalgh * gcc/testsuite/gcc.dg/vect/vect-rounding-btrunc.c: New test. * gcc/testsuite/gcc.dg/vect/vect-rounding-btruncf.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-ceil.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-ceilf.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-floor.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-floorf.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-lceil.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-lfloor.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyint.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyintf.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-round.c: Likewise. * gcc/testsuite/gcc.dg/vect/vect-rounding-roundf.c: Likewise. * gcc/testsuite/lib/target-supports.exp (check_effective_target_vect_call_btrunc): New. (check_effective_target_vect_call_btruncf): Likewise. (check_effective_target_vect_call_ceil): Likewise. (check_effective_target_vect_call_ceilf): Likewise. (check_effective_target_vect_call_floor): Likewise. (check_effective_target_vect_call_floorf): Likewise. (check_effective_target_vect_call_lceil): Likewise. (check_effective_target_vect_call_lfloor): Likewise. (check_effective_target_vect_call_nearbyint): Likewise. (check_effective_target_vect_call_nearbyintf): Likewise. (check_effective_target_vect_call_round): Likewise. (check_effective_target_vect_call_roundf): Likewise. diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index 2cdda0f..a683afd 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -1221,3 +1221,70 @@ aarch64_expand_builtin (tree exp, return NULL_RTX; } + +tree +aarch64_builtin_vectorized_function (tree fndecl, tree type_out, tree type_in) +{ + enum machine_mode in_mode, out_mode; + int in_n, out_n; + + if (TREE_CODE (type_out) != VECTOR_TYPE + || TREE_CODE (type_in) != VECTOR_TYPE) + return NULL_TREE; + + out_mode = TYPE_MODE (TREE_TYPE (type_out)); + out_n = TYPE_VECTOR_SUBPARTS (type_out); + in_mode = TYPE_MODE (TREE_TYPE (type_in)); + in_n = TYPE_VECTOR_SUBPARTS (type_in); + +#undef AARCH64_CHECK_BUILTIN_MODE +#define AARCH64_CHECK_BUILTIN_MODE(C, N) 1 +#define AARCH64_FIND_FRINT_VARIANT(N) \ + (AARCH64_CHECK_BUILTIN_MODE (2, D) \ + ? aarch64_builtin_decls[AARCH64_SIMD_BUILTIN_##N##v2df] \ + : (AARCH64_CHECK_BUILTIN_MODE (4, S) \ + ? aarch64_builtin_decls[AARCH64_SIMD_BUILTIN_##N##v4sf] \ + : (AARCH64_CHECK_BUILTIN_MODE (2, S) \ + ? aarch64_builtin_decls[AARCH64_SIMD_BUILTIN_##N##v2sf] \ + : NULL_TREE))) + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) + { + enum built_in_function fn = DECL_FUNCTION_CODE (fndecl); + switch (fn) + { +#undef AARCH64_CHECK_BUILTIN_MODE +#define AARCH64_CHECK_BUILTIN_MODE(C, N) \ + (out_mode == N##Fmode && out_n == C \ + && in_mode == N##Fmode && in_n == C) + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + return AARCH64_FIND_FRINT_VARIANT (frintm); + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + return AARCH64_FIND_FRINT_VARIANT (frintp); + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + return AARCH64_FIND_FRINT_VARIANT (frintz); + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + return AARCH64_FIND_FRINT_VARIANT (frinta); + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + return AARCH64_FIND_FRINT_VARIANT (frinti); +#undef AARCH64_CHECK_BUILTIN_MODE +#define AARCH64_CHECK_BUILTIN_MODE(C, N) \ + (out_mode == N##Imode && out_n == C \ + && in_mode == N##Fmode && in_n == C) + case BUILT_IN_LFLOOR: + return AARCH64_FIND_FRINT_VARIANT (fcvtms); + case BUILT_IN_LCEIL: + return AARCH64_FIND_FRINT_VARIANT (fcvtps); + default: + return NULL_TREE; + } + } + + return NULL_TREE; +} +#undef AARCH64_CHECK_BUILTIN_MODE +#undef AARCH64_FIND_FRINT_VARIANT diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index ab84257..2110970 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -236,4 +236,9 @@ rtx aarch64_expand_builtin (tree exp, int ignore ATTRIBUTE_UNUSED); tree aarch64_builtin_decl (unsigned, bool ATTRIBUTE_UNUSED); +tree +aarch64_builtin_vectorized_function (tree fndecl, + tree type_out, + tree type_in); + #endif /* GCC_AARCH64_PROTOS_H */ diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def index 2e3c4e1..b344120 100644 --- a/gcc/config/aarch64/aarch64-simd-builtins.def +++ b/gcc/config/aarch64/aarch64-simd-builtins.def @@ -206,3 +206,21 @@ BUILTIN_VDQ_BHSI (BINOP, smin) BUILTIN_VDQ_BHSI (BINOP, umax) BUILTIN_VDQ_BHSI (BINOP, umin) + + /* Implemented by aarch64_frint. */ + BUILTIN_VDQF (UNOP, frintz) + BUILTIN_VDQF (UNOP, frintp) + BUILTIN_VDQF (UNOP, frintm) + BUILTIN_VDQF (UNOP, frinti) + BUILTIN_VDQF (UNOP, frintx) + BUILTIN_VDQF (UNOP, frinta) + + /* Implemented by aarch64_fcvt. */ + BUILTIN_VDQF (UNOP, fcvtzs) + BUILTIN_VDQF (UNOP, fcvtzu) + BUILTIN_VDQF (UNOP, fcvtas) + BUILTIN_VDQF (UNOP, fcvtau) + BUILTIN_VDQF (UNOP, fcvtps) + BUILTIN_VDQF (UNOP, fcvtpu) + BUILTIN_VDQF (UNOP, fcvtms) + BUILTIN_VDQF (UNOP, fcvtmu) diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index b3d01c1..8c9ceac 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -1240,6 +1240,46 @@ (set_attr "simd_mode" "")] ) +(define_insn "aarch64_frint" + [(set (match_operand:VDQF 0 "register_operand" "=w") + (unspec:VDQF [(match_operand:VDQF 1 "register_operand" "w")] + FRINT))] + "TARGET_SIMD" + "frint\\t%0., %1." + [(set_attr "simd_type" "simd_frint") + (set_attr "simd_mode" "")] +) + +;; Vector versions of the floating-point frint patterns. +;; Expands to btrunc, ceil, floor, nearbyint, rint, round. +(define_expand "2" + [(set (match_operand:VDQF 0 "register_operand") + (unspec:VDQF [(match_operand:VDQF 1 "register_operand")] + FRINT))] + "TARGET_SIMD" + {}) + +(define_insn "aarch64_fcvt" + [(set (match_operand: 0 "register_operand" "=w") + (FIXUORS: (unspec: + [(match_operand:VDQF 1 "register_operand" "w")] + FCVT)))] + "TARGET_SIMD" + "fcvt\\t%0., %1." + [(set_attr "simd_type" "simd_fcvti") + (set_attr "simd_mode" "")] +) + +;; Vector versions of the fcvt standard patterns. +;; Expands to lbtrunc, lround, lceil, lfloor +(define_expand "l2" + [(set (match_operand: 0 "register_operand") + (FIXUORS: (unspec: + [(match_operand:VDQF 1 "register_operand")] + FCVT)))] + "TARGET_SIMD" + {}) + (define_insn "aarch64_vmls" [(set (match_operand:VDQF 0 "register_operand" "=w") (minus:VDQF (match_operand:VDQF 1 "register_operand" "0") diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6241ba5..d60402d 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -6845,6 +6845,13 @@ aarch64_c_mode_for_suffix (char suffix) #undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE aarch64_preferred_simd_mode +#undef TARGET_VECTORIZE_BUILTINS +#define TARGET_VECTORIZE_BUILTINS + +#undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION +#define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \ + aarch64_builtin_vectorized_function + /* Section anchor support. */ #undef TARGET_MIN_ANCHOR_OFFSET diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 17f024f..b59d53d 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -2325,117 +2325,27 @@ ;; Floating-point intrinsics ;; ------------------------------------------------------------------- -;; trunc - nothrow +;; frint floating-point round to integral standard patterns. +;; Expands to btrunc, ceil, floor, nearbyint, rint, round. -(define_insn "btrunc2" +(define_insn "2" [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTZ))] + (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] + FRINT))] "TARGET_FLOAT" - "frintz\\t%0, %1" + "frint\\t%0, %1" [(set_attr "v8type" "frint") (set_attr "mode" "")] ) -(define_insn "*lbtrunc2" +;; frcvt floating-point round to integer and convert standard patterns. +;; Expands to lbtrunc, lceil, lfloor, lround. +(define_insn "l2" [(set (match_operand:GPI 0 "register_operand" "=r") - (FIXUORS:GPI (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTZ)))] + (FIXUORS:GPI (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] + FCVT)))] "TARGET_FLOAT" - "fcvtz\\t%0, %1" - [(set_attr "v8type" "fcvtf2i") - (set_attr "mode" "") - (set_attr "mode2" "")] -) - -;; ceil - nothrow - -(define_insn "ceil2" - [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTP))] - "TARGET_FLOAT" - "frintp\\t%0, %1" - [(set_attr "v8type" "frint") - (set_attr "mode" "")] -) - -(define_insn "lceil2" - [(set (match_operand:GPI 0 "register_operand" "=r") - (FIXUORS:GPI (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTP)))] - "TARGET_FLOAT" - "fcvtp\\t%0, %1" - [(set_attr "v8type" "fcvtf2i") - (set_attr "mode" "") - (set_attr "mode2" "")] -) - -;; floor - nothrow - -(define_insn "floor2" - [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTM))] - "TARGET_FLOAT" - "frintm\\t%0, %1" - [(set_attr "v8type" "frint") - (set_attr "mode" "")] -) - -(define_insn "lfloor2" - [(set (match_operand:GPI 0 "register_operand" "=r") - (FIXUORS:GPI (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTM)))] - "TARGET_FLOAT" - "fcvtm\\t%0, %1" - [(set_attr "v8type" "fcvtf2i") - (set_attr "mode" "") - (set_attr "mode2" "")] -) - -;; nearbyint - nothrow - -(define_insn "nearbyint2" - [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTI))] - "TARGET_FLOAT" - "frinti\\t%0, %1" - [(set_attr "v8type" "frint") - (set_attr "mode" "")] -) - -;; rint - -(define_insn "rint2" - [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTX))] - "TARGET_FLOAT" - "frintx\\t%0, %1" - [(set_attr "v8type" "frint") - (set_attr "mode" "")] -) - -;; round - nothrow - -(define_insn "round2" - [(set (match_operand:GPF 0 "register_operand" "=w") - (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTA))] - "TARGET_FLOAT" - "frinta\\t%0, %1" - [(set_attr "v8type" "frint") - (set_attr "mode" "")] -) - -(define_insn "lround2" - [(set (match_operand:GPI 0 "register_operand" "=r") - (FIXUORS:GPI (unspec:GPF [(match_operand:GPF 1 "register_operand" "w")] - UNSPEC_FRINTA)))] - "TARGET_FLOAT" - "fcvta\\t%0, %1" + "fcvt\\t%0, %1" [(set_attr "v8type" "fcvtf2i") (set_attr "mode" "") (set_attr "mode2" "")] diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 7a1cdc8..31bc977 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -453,6 +453,9 @@ (define_mode_attr atomic_sfx [(QI "b") (HI "h") (SI "") (DI "")]) +(define_mode_attr fcvt_target [(V2DF "v2di") (V4SF "v4si") (V2SF "v2si")]) +(define_mode_attr FCVT_TARGET [(V2DF "V2DI") (V4SF "V4SI") (V2SF "V2SI")]) + ;; ------------------------------------------------------------------- ;; Code Iterators ;; ------------------------------------------------------------------- @@ -647,6 +650,12 @@ (define_int_iterator VCMP_U [UNSPEC_CMHS UNSPEC_CMHI UNSPEC_CMTST]) +(define_int_iterator FRINT [UNSPEC_FRINTZ UNSPEC_FRINTP UNSPEC_FRINTM + UNSPEC_FRINTI UNSPEC_FRINTX UNSPEC_FRINTA]) + +(define_int_iterator FCVT [UNSPEC_FRINTZ UNSPEC_FRINTP UNSPEC_FRINTM + UNSPEC_FRINTA]) + ;; ------------------------------------------------------------------- ;; Int Iterators Attributes. ;; ------------------------------------------------------------------- @@ -729,3 +738,19 @@ (define_int_attr offsetlr [(UNSPEC_SSLI "1") (UNSPEC_USLI "1") (UNSPEC_SSRI "0") (UNSPEC_USRI "0")]) +;; Standard pattern names for floating-point rounding instructions. +(define_int_attr frint_pattern [(UNSPEC_FRINTZ "btrunc") + (UNSPEC_FRINTP "ceil") + (UNSPEC_FRINTM "floor") + (UNSPEC_FRINTI "nearbyint") + (UNSPEC_FRINTX "rint") + (UNSPEC_FRINTA "round")]) + +;; frint suffix for floating-point rounding instructions. +(define_int_attr frint_suffix [(UNSPEC_FRINTZ "z") (UNSPEC_FRINTP "p") + (UNSPEC_FRINTM "m") (UNSPEC_FRINTI "i") + (UNSPEC_FRINTX "x") (UNSPEC_FRINTA "a")]) + +(define_int_attr fcvt_pattern [(UNSPEC_FRINTZ "btrunc") (UNSPEC_FRINTA "round") + (UNSPEC_FRINTP "ceil") (UNSPEC_FRINTM "floor")]) + diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-btrunc.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-btrunc.c new file mode 100644 index 0000000..7432fe7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-btrunc.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_btrunc } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_trunc (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_btrunc } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-btruncf.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-btruncf.c new file mode 100644 index 0000000..0835e1b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-btruncf.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_btruncf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_truncf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_btruncf } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-ceil.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-ceil.c new file mode 100644 index 0000000..a430690 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-ceil.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_ceil } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_ceil (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_ceil } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-ceilf.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-ceilf.c new file mode 100644 index 0000000..4d00924 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-ceilf.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_ceilf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_ceilf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_ceilf } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-floor.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-floor.c new file mode 100644 index 0000000..8f1c9ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-floor.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_floor } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_floor (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_floor } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-floorf.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-floorf.c new file mode 100644 index 0000000..a68c2ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-floorf.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_floorf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_floorf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_floorf } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-lceil.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-lceil.c new file mode 100644 index 0000000..b4ed236 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-lceil.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_lceil } */ + +#define N 32 + +void +foo (long *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_lceil (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_lceil } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-lfloor.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-lfloor.c new file mode 100644 index 0000000..5a36631 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-lfloor.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_lfloor } */ + +#define N 32 + +void +foo (long *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_lfloor (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_lfloor } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyint.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyint.c new file mode 100644 index 0000000..572dbd3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyint.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_nearbyint } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_nearbyint (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_nearbyint } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyintf.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyintf.c new file mode 100644 index 0000000..73ca7de --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-nearbyintf.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_nearbyintf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_nearbyintf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_nearbyintf } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-round.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-round.c new file mode 100644 index 0000000..c298bbb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-round.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_round } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_round (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_round } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-rounding-roundf.c b/gcc/testsuite/gcc.dg/vect/vect-rounding-roundf.c new file mode 100644 index 0000000..362b9d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-rounding-roundf.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_roundf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_roundf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_roundf } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 5935346..59d854f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -3925,6 +3925,222 @@ proc check_effective_target_vect_call_lrint { } { return $et_vect_call_lrint } +# Return 1 if the target supports vector btrunc calls. + +proc check_effective_target_vect_call_btrunc { } { + global et_vect_call_btrunc_saved + + if [info exists et_vect_call_btrunc_saved] { + verbose "check_effective_target_vect_call_btrunc: using cached result" 2 + } else { + set et_vect_call_btrunc_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_btrunc_saved 1 + } + } + + verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2 + return $et_vect_call_btrunc_saved +} + +# Return 1 if the target supports vector btruncf calls. + +proc check_effective_target_vect_call_btruncf { } { + global et_vect_call_btruncf_saved + + if [info exists et_vect_call_btruncf_saved] { + verbose "check_effective_target_vect_call_btruncf: using cached result" 2 + } else { + set et_vect_call_btruncf_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_btruncf_saved 1 + } + } + + verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2 + return $et_vect_call_btruncf_saved +} + +# Return 1 if the target supports vector ceil calls. + +proc check_effective_target_vect_call_ceil { } { + global et_vect_call_ceil_saved + + if [info exists et_vect_call_ceil_saved] { + verbose "check_effective_target_vect_call_ceil: using cached result" 2 + } else { + set et_vect_call_ceil_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_ceil_saved 1 + } + } + + verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2 + return $et_vect_call_ceil_saved +} + +# Return 1 if the target supports vector ceilf calls. + +proc check_effective_target_vect_call_ceilf { } { + global et_vect_call_ceilf_saved + + if [info exists et_vect_call_ceilf_saved] { + verbose "check_effective_target_vect_call_ceilf: using cached result" 2 + } else { + set et_vect_call_ceilf_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_ceilf_saved 1 + } + } + + verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2 + return $et_vect_call_ceilf_saved +} + +# Return 1 if the target supports vector floor calls. + +proc check_effective_target_vect_call_floor { } { + global et_vect_call_floor_saved + + if [info exists et_vect_call_floor_saved] { + verbose "check_effective_target_vect_call_floor: using cached result" 2 + } else { + set et_vect_call_floor_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_floor_saved 1 + } + } + + verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2 + return $et_vect_call_floor_saved +} + +# Return 1 if the target supports vector floorf calls. + +proc check_effective_target_vect_call_floorf { } { + global et_vect_call_floorf_saved + + if [info exists et_vect_call_floorf_saved] { + verbose "check_effective_target_vect_call_floorf: using cached result" 2 + } else { + set et_vect_call_floorf_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_floorf_saved 1 + } + } + + verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2 + return $et_vect_call_floorf_saved +} + +# Return 1 if the target supports vector lceil calls. + +proc check_effective_target_vect_call_lceil { } { + global et_vect_call_lceil_saved + + if [info exists et_vect_call_lceil_saved] { + verbose "check_effective_target_vect_call_lceil: using cached result" 2 + } else { + set et_vect_call_lceil_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_lceil_saved 1 + } + } + + verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2 + return $et_vect_call_lceil_saved +} + +# Return 1 if the target supports vector lfloor calls. + +proc check_effective_target_vect_call_lfloor { } { + global et_vect_call_lfloor_saved + + if [info exists et_vect_call_lfloor_saved] { + verbose "check_effective_target_vect_call_lfloor: using cached result" 2 + } else { + set et_vect_call_lfloor_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_lfloor_saved 1 + } + } + + verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2 + return $et_vect_call_lfloor_saved +} + +# Return 1 if the target supports vector nearbyint calls. + +proc check_effective_target_vect_call_nearbyint { } { + global et_vect_call_nearbyint_saved + + if [info exists et_vect_call_nearbyint_saved] { + verbose "check_effective_target_vect_call_nearbyint: using cached result" 2 + } else { + set et_vect_call_nearbyint_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_nearbyint_saved 1 + } + } + + verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2 + return $et_vect_call_nearbyint_saved +} + +# Return 1 if the target supports vector nearbyintf calls. + +proc check_effective_target_vect_call_nearbyintf { } { + global et_vect_call_nearbyintf_saved + + if [info exists et_vect_call_nearbyintf_saved] { + verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2 + } else { + set et_vect_call_nearbyintf_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_nearbyintf_saved 1 + } + } + + verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2 + return $et_vect_call_nearbyintf_saved +} + +# Return 1 if the target supports vector round calls. + +proc check_effective_target_vect_call_round { } { + global et_vect_call_round_saved + + if [info exists et_vect_call_round_saved] { + verbose "check_effective_target_vect_call_round: using cached result" 2 + } else { + set et_vect_call_round_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_round_saved 1 + } + } + + verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2 + return $et_vect_call_round_saved +} + +# Return 1 if the target supports vector roundf calls. + +proc check_effective_target_vect_call_roundf { } { + global et_vect_call_roundf_saved + + if [info exists et_vect_call_roundf_saved] { + verbose "check_effective_target_vect_call_roundf: using cached result" 2 + } else { + set et_vect_call_roundf_saved 0 + if { [istarget aarch64*-*-*] } { + set et_vect_call_roundf_saved 1 + } + } + + verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2 + return $et_vect_call_roundf_saved +} + # Return 1 if the target supports section-anchors proc check_effective_target_section_anchors { } {