From patchwork Tue Jun 30 03:54:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 50442 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9FFCC218E4 for ; Tue, 30 Jun 2015 03:54:53 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf30778282wgj.3 for ; Mon, 29 Jun 2015 20:54:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=HVVUwpw1s+3yhyA7/mCf1THViKWrhdeUTVnVyjuLE5Q=; b=Kh4XC3bep2m6nJ72irSy3Ks4khAGulJBWCG2e/w1IOPWCX5ouGZo4YKeySvtI1D5eh at27xnImAxOla3mXjU5xAts8PFo3eoE18SN0SpgELkMNY6S04QXTTG6X1GAn0hr/8oNG 94TYsqAd+Vnq3OyjHLk39XzkA5233tPOOzG7YuQM1PFLA95gzfWPH3u+EORtYzkKkC1Y oK9Ifg4GNk7+LgjIjHfydw6WeSo7TB/OmopkSCp3gT/Z8j8kMbZ3A++9xrPi3suzzR8U v8NF4oqNTZRYKwCerRGyXigcYjGDcb4EfyVYhuh03wJuZ7+mlbQLRBir3KMmgYQfCW49 h5sQ== X-Gm-Message-State: ALoCoQm2xOf1MUzB98HTUk+KFb1Utd714kmCYkQtOblY41fNs8uePoLBzSIu+gy3AEvilON9RhGa X-Received: by 10.152.5.2 with SMTP id o2mr12818419lao.0.1435636492398; Mon, 29 Jun 2015 20:54:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.97 with SMTP id c1ls761656laf.66.gmail; Mon, 29 Jun 2015 20:54:52 -0700 (PDT) X-Received: by 10.152.43.110 with SMTP id v14mr17403087lal.4.1435636492179; Mon, 29 Jun 2015 20:54:52 -0700 (PDT) Received: from mail-la0-x22e.google.com (mail-la0-x22e.google.com. [2a00:1450:4010:c03::22e]) by mx.google.com with ESMTPS id ql5si36873648lbb.165.2015.06.29.20.54.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 20:54:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22e as permitted sender) client-ip=2a00:1450:4010:c03::22e; Received: by lagc2 with SMTP id c2so32748284lag.3 for ; Mon, 29 Jun 2015 20:54:51 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr17224825lbc.112.1435636491400; Mon, 29 Jun 2015 20:54:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2145433lbb; Mon, 29 Jun 2015 20:54:49 -0700 (PDT) X-Received: by 10.66.163.38 with SMTP id yf6mr38830443pab.115.1435636489004; Mon, 29 Jun 2015 20:54:49 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id el11si67762709pac.237.2015.06.29.20.54.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 20:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-401604-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 67028 invoked by alias); 30 Jun 2015 03:54:34 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 67016 invoked by uid 89); 30 Jun 2015 03:54:32 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, 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; Tue, 30 Jun 2015 03:54:30 +0000 Received: by pabvl15 with SMTP id vl15so115472379pab.1 for ; Mon, 29 Jun 2015 20:54:28 -0700 (PDT) X-Received: by 10.70.36.139 with SMTP id q11mr39451096pdj.38.1435636468405; Mon, 29 Jun 2015 20:54:28 -0700 (PDT) Received: from [10.1.1.6] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by mx.google.com with ESMTPSA id he9sm43743995pbc.7.2015.06.29.20.54.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 20:54:27 -0700 (PDT) Message-ID: <559212EF.7080301@linaro.org> Date: Tue, 30 Jun 2015 13:54:23 +1000 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Maxim Kuvyrkov CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH 1/2] Allow REG_EQUAL for ZERO_EXTRACT References: <558FD9D5.9070703@linaro.org> <558FDA78.9030606@linaro.org> In-Reply-To: X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22e as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 On 29/06/15 21:56, Maxim Kuvyrkov wrote: >> On Jun 28, 2015, at 2:28 PM, Kugan wrote: >> >> This patch allows setting REG_EQUAL for ZERO_EXTRACT and handle that in >> cse (where the src for the ZERO_EXTRACT needs to be calculated) >> >> Thanks, >> Kugan > >> From 75e746e559ffd21b25542b3db627e3b318118569 Mon Sep 17 00:00:00 2001 >> From: Kugan Vivekanandarajah >> Date: Fri, 26 Jun 2015 17:12:07 +1000 >> Subject: [PATCH 1/2] Allow adding REG_EQUAL for ZERO_EXTRACT >> >> --- >> gcc/ChangeLog | 6 ++++++ >> gcc/cse.c | 41 ++++++++++++++++++++++++++++++++++++++++- >> gcc/emit-rtl.c | 3 ++- >> 3 files changed, 48 insertions(+), 2 deletions(-) >> >> diff --git a/gcc/ChangeLog b/gcc/ChangeLog >> index 080aa39..d4a73d6 100644 >> --- a/gcc/ChangeLog >> +++ b/gcc/ChangeLog >> @@ -1,3 +1,9 @@ >> +2015-06-26 Kugan Vivekanandarajah >> + >> + * cse.c (cse_insn): Calculate src_eqv for ZERO_EXTRACT. >> + * emit-rtl.c (set_for_reg_notes): Allow ZERO_EXTRACT to set >> + REG_EQUAL note. >> + >> 2015-06-25 H.J. Lu >> >> * gentarget-def.c (def_target_insn): Cast return of strtol to >> diff --git a/gcc/cse.c b/gcc/cse.c >> index 100c9c8..8add651 100644 >> --- a/gcc/cse.c >> +++ b/gcc/cse.c >> @@ -4531,8 +4531,47 @@ cse_insn (rtx_insn *insn) >> if (n_sets == 1 && REG_NOTES (insn) != 0 >> && (tem = find_reg_note (insn, REG_EQUAL, NULL_RTX)) != 0 >> && (! rtx_equal_p (XEXP (tem, 0), SET_SRC (sets[0].rtl)) >> + || GET_CODE (SET_DEST (sets[0].rtl)) == ZERO_EXTRACT >> || GET_CODE (SET_DEST (sets[0].rtl)) == STRICT_LOW_PART)) >> - src_eqv = copy_rtx (XEXP (tem, 0)); >> + { >> + src_eqv = copy_rtx (XEXP (tem, 0)); >> + >> + /* If DEST is of the form ZERO_EXTACT, as in: >> + (set (zero_extract:SI (reg:SI 119) >> + (const_int 16 [0x10]) >> + (const_int 16 [0x10])) >> + (const_int 51154 [0xc7d2])) >> + REG_EQUAL note will specify the value of register (reg:SI 119) at this >> + point. Note that this is different from SRC_EQV. We can however >> + calculate SRC_EQV with the position and width of ZERO_EXTRACT. */ >> + if (GET_CODE (SET_DEST (sets[0].rtl)) == ZERO_EXTRACT) > > Consider changing > > if (something > && (!rtx_equal_p) > || ZERO_EXTRACT > || STRICT_LOW_PART) > > to > > if (something > && !rtx_equal_p) > { > if (ZERO_EXTRACT) > { > } > else if (STRICT_LOW_PART) > { > } > } > > Otherwise looks good to me, but you still need another approval. Thanks Maxim for the review. How about the attached patch? Thanks, Kugan > > >> + { >> + if (CONST_INT_P (src_eqv) >> + && CONST_INT_P (XEXP (SET_DEST (sets[0].rtl), 1)) >> + && CONST_INT_P (XEXP (SET_DEST (sets[0].rtl), 2))) >> + { >> + rtx dest_reg = XEXP (SET_DEST (sets[0].rtl), 0); >> + rtx width = XEXP (SET_DEST (sets[0].rtl), 1); >> + rtx pos = XEXP (SET_DEST (sets[0].rtl), 2); >> + HOST_WIDE_INT val = INTVAL (src_eqv); >> + HOST_WIDE_INT mask; >> + unsigned int shift; >> + if (BITS_BIG_ENDIAN) >> + shift = GET_MODE_PRECISION (GET_MODE (dest_reg)) >> + - INTVAL (pos) - INTVAL (width); >> + else >> + shift = INTVAL (pos); >> + if (INTVAL (width) == HOST_BITS_PER_WIDE_INT) >> + mask = ~(HOST_WIDE_INT) 0; >> + else >> + mask = ((HOST_WIDE_INT) 1 << INTVAL (width)) - 1; >> + val = (val >> shift) & mask; >> + src_eqv = GEN_INT (val); >> + } >> + else >> + src_eqv = 0; >> + } >> + } >> >> /* Set sets[i].src_elt to the class each source belongs to. >> Detect assignments from or to volatile things >> diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c >> index e7f7eab..cb891b1 100644 >> --- a/gcc/emit-rtl.c >> +++ b/gcc/emit-rtl.c >> @@ -5228,7 +5228,8 @@ set_for_reg_notes (rtx insn) >> reg = SET_DEST (pat); >> >> /* Notes apply to the contents of a STRICT_LOW_PART. */ >> - if (GET_CODE (reg) == STRICT_LOW_PART) >> + if (GET_CODE (reg) == STRICT_LOW_PART >> + || GET_CODE (reg) == ZERO_EXTRACT) >> reg = XEXP (reg, 0); >> >> /* Check that we have a register. */ >> -- >> 1.9.1 >> >> > > > -- > Maxim Kuvyrkov > www.linaro.org > > > > >From 3754bcd11fb732e03a39d6625a9eb14934b36643 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 26 Jun 2015 17:12:07 +1000 Subject: [PATCH 1/2] Allow adding REG_EQUAL for ZERO_EXTRACT --- gcc/ChangeLog | 6 ++++++ gcc/cse.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- gcc/emit-rtl.c | 3 ++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 080aa39..d4a73d6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-06-26 Kugan Vivekanandarajah + + * cse.c (cse_insn): Calculate src_eqv for ZERO_EXTRACT. + * emit-rtl.c (set_for_reg_notes): Allow ZERO_EXTRACT to set + REG_EQUAL note. + 2015-06-25 H.J. Lu * gentarget-def.c (def_target_insn): Cast return of strtol to diff --git a/gcc/cse.c b/gcc/cse.c index 100c9c8..ea9e989 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -4525,14 +4525,49 @@ cse_insn (rtx_insn *insn) canonicalize_insn (insn, &sets, n_sets); /* If this insn has a REG_EQUAL note, store the equivalent value in SRC_EQV, - if different, or if the DEST is a STRICT_LOW_PART. The latter condition - is necessary because SRC_EQV is handled specially for this case, and if - it isn't set, then there will be no equivalence for the destination. */ + if different, or if the DEST is a STRICT_LOW_PART/ZERO_EXTRACT. The + latter condition is necessary because SRC_EQV is handled specially for + this case, and if it isn't set, then there will be no equivalence + for the destination. */ if (n_sets == 1 && REG_NOTES (insn) != 0 - && (tem = find_reg_note (insn, REG_EQUAL, NULL_RTX)) != 0 - && (! rtx_equal_p (XEXP (tem, 0), SET_SRC (sets[0].rtl)) - || GET_CODE (SET_DEST (sets[0].rtl)) == STRICT_LOW_PART)) - src_eqv = copy_rtx (XEXP (tem, 0)); + && (tem = find_reg_note (insn, REG_EQUAL, NULL_RTX)) != 0) + { + if ((! rtx_equal_p (XEXP (tem, 0), SET_SRC (sets[0].rtl))) + || GET_CODE (SET_DEST (sets[0].rtl)) == STRICT_LOW_PART) + src_eqv = copy_rtx (XEXP (tem, 0)); + + /* If DEST is of the form ZERO_EXTACT, as in: + (set (zero_extract:SI (reg:SI 119) + (const_int 16 [0x10]) + (const_int 16 [0x10])) + (const_int 51154 [0xc7d2])) + REG_EQUAL note will specify the value of register (reg:SI 119) at this + point. Note that this is different from SRC_EQV. We can however + calculate SRC_EQV with the position and width of ZERO_EXTRACT. */ + else if (GET_CODE (SET_DEST (sets[0].rtl)) == ZERO_EXTRACT + &&CONST_INT_P (src_eqv) + && CONST_INT_P (XEXP (SET_DEST (sets[0].rtl), 1)) + && CONST_INT_P (XEXP (SET_DEST (sets[0].rtl), 2))) + { + rtx dest_reg = XEXP (SET_DEST (sets[0].rtl), 0); + rtx width = XEXP (SET_DEST (sets[0].rtl), 1); + rtx pos = XEXP (SET_DEST (sets[0].rtl), 2); + HOST_WIDE_INT val = INTVAL (src_eqv); + HOST_WIDE_INT mask; + unsigned int shift; + if (BITS_BIG_ENDIAN) + shift = GET_MODE_PRECISION (GET_MODE (dest_reg)) + - INTVAL (pos) - INTVAL (width); + else + shift = INTVAL (pos); + if (INTVAL (width) == HOST_BITS_PER_WIDE_INT) + mask = ~(HOST_WIDE_INT) 0; + else + mask = ((HOST_WIDE_INT) 1 << INTVAL (width)) - 1; + val = (val >> shift) & mask; + src_eqv = GEN_INT (val); + } + } /* Set sets[i].src_elt to the class each source belongs to. Detect assignments from or to volatile things diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e7f7eab..cb891b1 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -5228,7 +5228,8 @@ set_for_reg_notes (rtx insn) reg = SET_DEST (pat); /* Notes apply to the contents of a STRICT_LOW_PART. */ - if (GET_CODE (reg) == STRICT_LOW_PART) + if (GET_CODE (reg) == STRICT_LOW_PART + || GET_CODE (reg) == ZERO_EXTRACT) reg = XEXP (reg, 0); /* Check that we have a register. */ -- 1.9.1