From patchwork Thu Sep 18 12:05:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Lawrence X-Patchwork-Id: 390777 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5DD891401AF for ; Thu, 18 Sep 2014 22:05:22 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=ip9esyD9xN/RVOh4W a49+cSq8oY7lPlh5FHM8Dk3KnCrAQT8+P5SWU5pXPpcX7KPuMav1AWQuCPc3/k0v nGviDuWHaAxkjqQUtuZzrZvtLifM/2mxcmLzwePnAtYku/SFLKyKE0bv4rr8W2UO 4HLXqSIvxsp3ms89TeX/hFx474= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=TkVcaWO7HVWx3A1R/AsSjd5 Vol8=; b=vnA2w9oMr0Jprn3YZ3CRbdf8agG5rOHoes/Caau3fVDvSDDWE1sw9Re xkajjWtq3KFEOKAVMm626Kpda1v8xjG8yVcxWZ+h8hLl9XlhfiV4L0O+5nh3j3Qk crSYR7cHmMihTryOvHBtqHm0rKZRmfRPbHUkj0L98XhdpXIOWuOc= Received: (qmail 7919 invoked by alias); 18 Sep 2014 12:05:15 -0000 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 Received: (qmail 7905 invoked by uid 89); 18 Sep 2014 12:05:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Sep 2014 12:05:13 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 18 Sep 2014 13:05:11 +0100 Received: from [10.1.209.51] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Sep 2014 13:05:11 +0100 Message-ID: <541ACA76.5030107@arm.com> Date: Thu, 18 Sep 2014 13:05:10 +0100 From: Alan Lawrence User-Agent: Thunderbird 2.0.0.24 (X11/20101213) MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH 6/14][AArch64] Restore gimple_folding of reduction intrinsics References: <541AC4D2.9040901@arm.com> In-Reply-To: <541AC4D2.9040901@arm.com> X-MC-Unique: 114091813051102401 X-IsSubscribed: yes This gives us back the constant-folding of the neon-intrinsics that was removed in the first patch, but is now OK for bigendian too. bootstrapped on aarch64-none-linux-gnu. check-gcc on aarch64-none-elf and aarch64_be-none-elf. gcc/ChangeLog: * config/aarch64/aarch64.c (TARGET_GIMPLE_FOLD_BUILTIN): Define again. * config/aarch64/aarch64-builtins.c (aarch64_gimple_fold_builtin): Restore, enable for bigendian, update to use __builtin..._scal... diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index 15eb7c686d95b1d66cbd514500ec29ba074eaa3f..0432d3aa1a515a15b051ba89afec7c0306cb5803 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -1333,9 +1333,6 @@ aarch64_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *args, return NULL_TREE; } -/* Handling of reduction operations temporarily removed so as to decouple - changes to tree codes from AArch64 NEON Intrinsics. */ -#if 0 bool aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi) { @@ -1345,19 +1342,6 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi) tree fndecl; gimple new_stmt = NULL; - /* The operations folded below are reduction operations. These are - defined to leave their result in the 0'th element (from the perspective - of GCC). The architectural instruction we are folding will leave the - result in the 0'th element (from the perspective of the architecture). - For big-endian systems, these perspectives are not aligned. - - It is therefore wrong to perform this fold on big-endian. There - are some tricks we could play with shuffling, but the mid-end is - inconsistent in the way it treats reduction operations, so we will - end up in difficulty. Until we fix the ambiguity - just bail out. */ - if (BYTES_BIG_ENDIAN) - return false; - if (call) { fndecl = gimple_call_fndecl (stmt); @@ -1369,23 +1353,28 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi) ? gimple_call_arg_ptr (stmt, 0) : &error_mark_node); + /* We use gimple's REDUC_(PLUS|MIN|MAX)_EXPRs for float, signed int + and unsigned int; it will distinguish according to the types of + the arguments to the __builtin. */ switch (fcode) { - BUILTIN_VALL (UNOP, reduc_splus_, 10) - new_stmt = gimple_build_assign_with_ops ( + BUILTIN_VALL (UNOP, reduc_plus_scal_, 10) + new_stmt = gimple_build_assign_with_ops ( REDUC_PLUS_EXPR, gimple_call_lhs (stmt), args[0], NULL_TREE); break; - BUILTIN_VDQIF (UNOP, reduc_smax_, 10) + BUILTIN_VDQIF (UNOP, reduc_smax_scal_, 10) + BUILTIN_VDQ_BHSI (UNOPU, reduc_umax_scal_, 10) new_stmt = gimple_build_assign_with_ops ( REDUC_MAX_EXPR, gimple_call_lhs (stmt), args[0], NULL_TREE); break; - BUILTIN_VDQIF (UNOP, reduc_smin_, 10) + BUILTIN_VDQIF (UNOP, reduc_smin_scal_, 10) + BUILTIN_VDQ_BHSI (UNOPU, reduc_umin_scal_, 10) new_stmt = gimple_build_assign_with_ops ( REDUC_MIN_EXPR, gimple_call_lhs (stmt), @@ -1407,7 +1396,6 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi) return changed; } -#endif void aarch64_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 9197ec038b7d40a601c886b846113c50a29cf5e2..e7946fc0b70ced70a4e98caa0a33121f29242aad 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -9925,8 +9925,8 @@ aarch64_expand_movmem (rtx *operands) #undef TARGET_FRAME_POINTER_REQUIRED #define TARGET_FRAME_POINTER_REQUIRED aarch64_frame_pointer_required -//#undef TARGET_GIMPLE_FOLD_BUILTIN -//#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin +#undef TARGET_GIMPLE_FOLD_BUILTIN +#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin #undef TARGET_GIMPLIFY_VA_ARG_EXPR #define TARGET_GIMPLIFY_VA_ARG_EXPR aarch64_gimplify_va_arg_expr