From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76216 invoked by alias); 12 Aug 2015 01:11:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 76164 invoked by uid 89); 12 Aug 2015 01:11:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 12 Aug 2015 01:11:54 +0000 Received: by pabyb7 with SMTP id yb7so2253969pab.0 for ; Tue, 11 Aug 2015 18:11:52 -0700 (PDT) X-Received: by 10.66.175.7 with SMTP id bw7mr55846238pac.155.1439341911989; Tue, 11 Aug 2015 18:11:51 -0700 (PDT) Received: from bigtime.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by smtp.gmail.com with ESMTPSA id kv10sm4167810pbc.2.2015.08.11.18.11.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Aug 2015 18:11:51 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: [PATCH 05/15] rs6000: Move constant via mask into build_set_const_data Date: Wed, 12 Aug 2015 01:11:00 -0000 Message-Id: <1439341904-9345-6-git-send-email-rth@redhat.com> In-Reply-To: <1439341904-9345-1-git-send-email-rth@redhat.com> References: <1439341904-9345-1-git-send-email-rth@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00550.txt.bz2 No need to special-case this in several places anymore. Cc: David Edelsohn --- * config/rs6000/rs6000.c (num_insns_constant): Remove test for rs6000_is_valid_and_mask. (genimm_ppc::exam_mask): New. (genimm_ppc::exam_search): Use it. (genimm_ppc::generate): Handle AND. * config/rs6000/rs6000.md (rs6000_is_valid_and_mask splitter): Remove. --- gcc/config/rs6000/rs6000.c | 27 ++++++++++++++++++++++----- gcc/config/rs6000/rs6000.md | 15 --------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a864a7e..6af5cf3 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5246,11 +5246,7 @@ num_insns_constant (rtx op, machine_mode mode) switch (GET_CODE (op)) { case CONST_INT: - if ((INTVAL (op) >> 31) != 0 && (INTVAL (op) >> 31) != -1 - && rs6000_is_valid_and_mask (op, mode)) - return 2; - else - return num_insns_constant_wide (INTVAL (op)); + return num_insns_constant_wide (INTVAL (op)); case CONST_WIDE_INT: { @@ -8062,6 +8058,7 @@ struct genimm_ppc : genimm_base bool exam_simple (HOST_WIDE_INT c, machine_mode, int budget); bool exam_sub (HOST_WIDE_INT c, int budget); + bool exam_mask (HOST_WIDE_INT c, HOST_WIDE_INT mask, int sub_budget); bool exam_search (HOST_WIDE_INT c, int budget); void exam_full (HOST_WIDE_INT c); void generate (rtx dest, machine_mode mode) const; @@ -8125,6 +8122,21 @@ genimm_ppc::exam_sub (HOST_WIDE_INT c, int budget) || (budget > 1 && exam_search (c, budget))); } +/* If we are able to construct C within SUB_BUDGET + 1, + return true and fill in the recipe. */ + +bool +genimm_ppc::exam_mask (HOST_WIDE_INT c, HOST_WIDE_INT mask, int sub_budget) +{ + if (rs6000_is_valid_and_mask_wide (mask, DImode) + && exam_sub (c, sub_budget)) + { + opN (AND, mask); /* RLDICL, et al */ + return true; + } + return false; +} + /* The body of the recursive search for C within BUDGET. We've already failed exam_simple. */ @@ -8157,6 +8169,10 @@ genimm_ppc::exam_search (HOST_WIDE_INT c, int budget) } } + /* If C is a mask itself, apply it to all ones. */ + if (exam_mask (-1, c, sub_budget)) + return true; + /* Shift the constant left. */ test = HOST_WIDE_INT_UC (0xffffffff00000000); if ((c & test) == c && exam_sub (c >> 32, sub_budget)) @@ -8209,6 +8225,7 @@ genimm_ppc::generate (rtx dest, machine_mode mode) const x = op2; break; case PLUS: + case AND: case IOR: case ASHIFT: x = gen_rtx_fmt_ee (r, mode, op1, op2); diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 527ad98..9161931 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -7106,21 +7106,6 @@ [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,mftgpr,mffgpr,mftgpr,mffgpr,vecsimple") (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4,4,4")]) -; Some DImode loads are best done as a load of -1 followed by a mask -; instruction. -(define_split - [(set (match_operand:DI 0 "gpc_reg_operand") - (match_operand:DI 1 "const_int_operand"))] - "TARGET_POWERPC64 - && num_insns_constant (operands[1], DImode) > 1 - && rs6000_is_valid_and_mask (operands[1], DImode)" - [(set (match_dup 0) - (const_int -1)) - (set (match_dup 0) - (and:DI (match_dup 0) - (match_dup 1)))] - "") - ;; Split a load of a large constant into the appropriate five-instruction ;; sequence. Handle anything in a constant number of insns. ;; When non-easy constants can go in the TOC, this should use -- 2.4.3