From patchwork Thu Aug 16 17:14:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 958508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483795-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FbYwvVUg"; dkim-atps=neutral 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 41rtHz3FjKz9s4V for ; Fri, 17 Aug 2018 03:15:11 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=W641xOgqKKtFk4vZy6i hw+EIyxFQC2WshQy5fSoh6IgUIInlB8dTK0qffU5+lxOT4Tlj7HMPWYztdXQKFlm 1r67sEmkuRxBGiJIga8cOl0FexznurfzS8IMIIpV/B1sYRMXgyyXKkyrqlfPazKa nV8b+RglnUePUjKbxD1dVOe4= 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:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=qWJGouTQwWXpySGESUPUb3Kn5 gk=; b=FbYwvVUgzAMbS+BoFE6i6T7F+UkOgo/oNGC2h0fE+rq3jS4n8l/apa0Om CduC5G/Cr8k93zlnI+zp1K9gQtovmgkrHWkQrTWh0z12ZTbx9/WtTK4daXmxnUuz FUYpUf/u6DOOQ0dGlY/djQOThiftxdO5YGnLRXICDW8nAO+BJ8= Received: (qmail 99467 invoked by alias); 16 Aug 2018 17:14:53 -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 99358 invoked by uid 89); 16 Aug 2018 17:14:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=CTR X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Aug 2018 17:14:51 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 5CFBB12407B4; Thu, 16 Aug 2018 17:14:50 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 1/4] rs6000: Change the length attribute default Date: Thu, 16 Aug 2018 17:14:38 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes This moves what is currently the default of the length attribute to the only branch instruction patterns where it applies, namely, the B-form instructions. It was used for the "jump" instruction as well before, but that is an I-form instruction and always has length 4. 2018-08-16 Segher Boessenkool * config/rs6000/rs6000.md (length): Always define as const_int 4. (unnamed conditional branch define_insn): Set length to 4 or 8 depending on offset. (_): Similar, for alternative 0. (tf_): Ditto. --- gcc/config/rs6000/rs6000.md | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index d70b01b..45e42ff 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -243,18 +243,8 @@ (define_attr "var_shift" "no,yes" ;; Is copying of this instruction disallowed? (define_attr "cannot_copy" "no,yes" (const_string "no")) -;; Length (in bytes). -; '(pc)' in the following doesn't include the instruction itself; it is -; calculated as if the instruction had zero size. -(define_attr "length" "" - (if_then_else (eq_attr "type" "branch") - (if_then_else (and (ge (minus (match_dup 0) (pc)) - (const_int -32768)) - (lt (minus (match_dup 0) (pc)) - (const_int 32764))) - (const_int 4) - (const_int 8)) - (const_int 4))) +;; Length of the instruction (in bytes). +(define_attr "length" "" (const_int 4)) ;; Processor type -- this attribute must exactly match the processor_type ;; enumeration in rs6000-opts.h. @@ -12346,7 +12336,14 @@ (define_insn "" { return output_cbranch (operands[1], "%l0", 0, insn); } - [(set_attr "type" "branch")]) + [(set_attr "type" "branch") + (set (attr "length") + (if_then_else (and (ge (minus (match_dup 0) (pc)) + (const_int -32768)) + (lt (minus (match_dup 0) (pc)) + (const_int 32764))) + (const_int 4) + (const_int 8)))]) (define_insn "" [(set (pc) @@ -12716,7 +12713,17 @@ (define_insn "_" return " $+8\;b %l0"; } [(set_attr "type" "branch") - (set_attr "length" "*,16,20,20")]) + (set (attr "length") + (cond [(eq (symbol_ref "which_alternative") (const_int 0)) + (if_then_else (and (ge (minus (match_dup 0) (pc)) + (const_int -32768)) + (lt (minus (match_dup 0) (pc)) + (const_int 32764))) + (const_int 4) + (const_int 8)) + (eq (symbol_ref "which_alternative") (const_int 1)) + (const_int 16)] + (const_int 20)))]) ;; Now the splitter if we could not allocate the CTR register (define_split @@ -12795,7 +12802,17 @@ (define_insn "tf_" } } [(set_attr "type" "branch") - (set_attr "length" "*,16,20,20")]) + (set (attr "length") + (cond [(eq (symbol_ref "which_alternative") (const_int 0)) + (if_then_else (and (ge (minus (match_dup 0) (pc)) + (const_int -32768)) + (lt (minus (match_dup 0) (pc)) + (const_int 32764))) + (const_int 4) + (const_int 8)) + (eq (symbol_ref "which_alternative") (const_int 1)) + (const_int 16)] + (const_int 20)))]) ;; Now the splitter if we could not allocate the CTR register (define_split