From patchwork Thu Nov 28 11:29:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 294859 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 511392C008F for ; Thu, 28 Nov 2013 22:29:43 +1100 (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:content-type; q= dns; s=default; b=oVJzdcyYFI5w25aeV/cPBb3jVDg52xZ3CQDO2pDIfp7if2 8bOwKgIU2/otL/6je5TcmqcPiRUZS1CddIUap/nIjBGkbkGg6fItMZQvcCcVbhcl yAMiUbcEFaTVNRRH4LLgKhklSmncKf0JMilumBidym5GG5upLpuoHsUFGxMKE= 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:content-type; s= default; bh=Evq11RVmI6tojyYx2mmFoLPzyk4=; b=IEsG1hyTZvRtctYzubwk 7LMFfKdenuN3FVzLKcba18g5ZWv6SNt0alfyoKk26MRy7ezTyCl6PFP8RVt68WCp ANhOuHiZf9mSm1/uBccmTWicvWFylgecxoFEJapKhBn/ox0TiQh3LgAjpVMQrDfa mFUUek0aGLA6E/bMaEuqHeI= Received: (qmail 5319 invoked by alias); 28 Nov 2013 11:29:31 -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 5303 invoked by uid 89); 28 Nov 2013 11:29:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: service87.mimecast.com Received: from Unknown (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Nov 2013 11:29:26 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 28 Nov 2013 11:29:18 +0000 Received: from [10.1.203.80] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 Nov 2013 11:29:17 +0000 Message-ID: <5297290D.7090806@arm.com> Date: Thu, 28 Nov 2013 11:29:17 +0000 From: Tejas Belagod User-Agent: Thunderbird 2.0.0.18 (X11/20081120) MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [Patch, AArch64] Relax CANNOT_CHANGE_MODE_CLASS. X-MC-Unique: 113112811291803901 X-IsSubscribed: yes Hi, Currently, CANNOT_CHANGE_MODE_CLASS is too restrictive wrt the mode-changes it allows on FPREGs - it allows none at the moment. In fact, there are many mode changes that are safe and can be allowed. For example, in a pattern like: (subreg:SF (reg:V4SF v0) 0) it is legal to reduce this to (reg:SF v0) The attached patch helps parts of rtlanal.c make such decisions(eg. simplify_subreg_regno). Tested on aarch64-none-elf and aarch64_be-none-elf. OK for trunk? Thanks, Tejas Belagod ARM. Changelog: 2013-11-28 Tejas Belagod gcc/ * config/aarch64/aarch64-protos.h (aarch64_cannot_change_mode_class): Declare. * config/aarch64/aarch64.c (aarch64_cannot_change_mode_class): New. * config/aarch64/aarch64.h (CANNOT_CHANGE_MODE_CLASS): Change to call backend function aarch64_cannot_change_mode_class. diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 489fd1c..3dcc7c3 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -160,6 +160,9 @@ struct tune_params HOST_WIDE_INT aarch64_initial_elimination_offset (unsigned, unsigned); bool aarch64_bitmask_imm (HOST_WIDE_INT val, enum machine_mode); +bool aarch64_cannot_change_mode_class (enum machine_mode, + enum machine_mode, + enum reg_class); enum aarch64_symbol_type aarch64_classify_symbolic_expression (rtx, enum aarch64_symbol_context); bool aarch64_constant_address_p (rtx); diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b1b4eef..6567a1b 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -8209,6 +8209,42 @@ aarch64_vectorize_vec_perm_const_ok (enum machine_mode vmode, return ret; } +/* Implement target hook CANNOT_CHANGE_MODE_CLASS. */ +bool +aarch64_cannot_change_mode_class (enum machine_mode from, + enum machine_mode to, + enum reg_class rclass) +{ + /* Full-reg subregs are allowed on general regs or any class if they are + the same size. */ + if (GET_MODE_SIZE (from) == GET_MODE_SIZE (to) + || !reg_classes_intersect_p (FP_REGS, rclass)) + return false; + + /* Limited combinations of subregs are safe on FPREGs. Particularly, + 1. Vector Mode to Scalar mode where 1 unit of the vector is accessed. + 2. Scalar to Scalar for integer modes or same size float modes. + 3. Vector to Vector modes. */ + if (GET_MODE_SIZE (from) > GET_MODE_SIZE (to)) + { + if (aarch64_vector_mode_supported_p (from) + && GET_MODE_INNER (from) == to) + return false; + + if (GET_MODE_NUNITS (from) == 1 + && GET_MODE_NUNITS (to) == 1 + && (GET_MODE_CLASS (from) == MODE_INT + || from == to)) + return false; + + if (aarch64_vector_mode_supported_p (from) + && aarch64_vector_mode_supported_p (to)) + return false; + } + + return true; +} + #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST aarch64_address_cost diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index cead022..b58fe04 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -818,13 +818,8 @@ do { \ extern void __aarch64_sync_cache_range (void *, void *); \ __aarch64_sync_cache_range (beg, end) -/* VFP registers may only be accessed in the mode they - were set. */ #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ - (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \ - ? reg_classes_intersect_p (FP_REGS, (CLASS)) \ - : 0) - + aarch64_cannot_change_mode_class (FROM, TO, CLASS) #define SHIFT_COUNT_TRUNCATED !TARGET_SIMD