public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sudakshina Das <sudi.das@arm.com>
To: Sameera Deshpande <sameera.deshpande@linaro.org>,
	James Greenhalgh <james.greenhalgh@arm.com>,
	Marcus Shawcroft <marcus.shawcroft@arm.com>,
	Richard Earnshaw <richard.earnshaw@arm.com>
Cc: Richard Sandiford <richard.sandiford@linaro.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	Ramana Radhakrishnan <ramana.gcc@googlemail.com>, nd <nd@arm.com>
Subject: Re: [Aarch64] Fix conditional branches with target far away.
Date: Thu, 15 Mar 2018 16:56:00 -0000	[thread overview]
Message-ID: <318513c3-9bee-6ef0-11cc-c7c43e5144a2@arm.com> (raw)
In-Reply-To: <CAAdirjw8nv424=7K__hvpaF37ka6d1-84AH5+niW6cW97XxfBQ@mail.gmail.com>

On 15/03/18 15:27, Sameera Deshpande wrote:
> Ping!
> 
> On 28 February 2018 at 16:18, Sameera Deshpande
> <sameera.deshpande@linaro.org> wrote:
>> On 27 February 2018 at 18:25, Ramana Radhakrishnan
>> <ramana.gcc@googlemail.com> wrote:
>>> On Wed, Feb 14, 2018 at 8:30 AM, Sameera Deshpande
>>> <sameera.deshpande@linaro.org> wrote:
>>>> Hi!
>>>>
>>>> Please find attached the patch to fix bug in branches with offsets over 1MiB.
>>>> There has been an attempt to fix this issue in commit
>>>> 050af05b9761f1979f11c151519e7244d5becd7c
>>>>
>>>> However, the far_branch attribute defined in above patch used
>>>> insn_length - which computes incorrect offset. Hence, eliminated the
>>>> attribute completely, and computed the offset from insn_addresses
>>>> instead.
>>>>
>>>> Ok for trunk?
>>>>
>>>> gcc/Changelog
>>>>
>>>> 2018-02-13 Sameera Deshpande <sameera.deshpande@linaro.org>
>>>>          * config/aarch64/aarch64.md (far_branch): Remove attribute. Eliminate
>>>>          all the dependencies on the attribute from RTL patterns.
>>>>
>>>
>>> I'm not a maintainer but this looks good to me modulo notes about how
>>> this was tested. What would be nice is a testcase for the testsuite as
>>> well as ensuring that the patch has been bootstrapped and regression
>>> tested. AFAIR, the original patch was put in because match.pd failed
>>> when bootstrap in another context.
>>>
>>>
>>> regards
>>> Ramana
>>>
>>>> --
>>>> - Thanks and regards,
>>>>    Sameera D.
>>
>> The patch is tested with GCC testsuite and bootstrapping successfully.
>> Also tested for spec benchmark.
>>

I am not a maintainer either. I noticed that the range check you do for
the offset has a (<= || >=). The "far_branch" however did (< || >=) for 
a positive value. Was that also part of the incorrect offset calculation?

@@ -692,7 +675,11 @@
     {
       if (get_attr_length (insn) =3D=3D 8)
         {
-       if (get_attr_far_branch (insn) =3D=3D 1)
+       long long int offset;
+       offset =3D INSN_ADDRESSES (INSN_UID (XEXP (operands[2], 0)))
+                 - INSN_ADDRESSES (INSN_UID (insn));
+
+       if (offset <=3D -1048576 || offset >=3D 1048572)
            return aarch64_gen_far_branch (operands, 2, "Ltb",
                                           "<inv_tb>\\t%<w>0, %1, ");
          else
@@ -709,12 +696,7 @@
          (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int
-32768))
                             (lt (minus (match_dup 2) (pc)) (const_int
32764)))
                        (const_int 4)
-                     (const_int 8)))
-   (set (attr "far_branch")
-       (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int
-1048576))
-                          (lt (minus (match_dup 2) (pc)) (const_int
1048572)))
-                     (const_int 0)
-                     (const_int 1)))]
+                     (const_int 8)))]

   )

Thanks
Sudi

>> --
>> - Thanks and regards,
>>    Sameera D.
> 
> 
> 

  reply	other threads:[~2018-03-15 16:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  8:30 Sameera Deshpande
2018-02-27 12:13 ` Sameera Deshpande
2018-02-27 12:55 ` Ramana Radhakrishnan
2018-02-28 10:48   ` Sameera Deshpande
2018-03-15 15:35     ` Sameera Deshpande
2018-03-15 16:56       ` Sudakshina Das [this message]
2018-03-22  2:10         ` Sameera Deshpande
2018-03-22 13:42           ` Sudakshina Das
2018-03-29 11:28             ` Sameera Deshpande
2018-03-29 15:33               ` Sudakshina Das
2018-03-29 15:35                 ` Sameera Deshpande
2018-03-29 15:54               ` Kyrill Tkachov
2018-03-30 11:24               ` Richard Sandiford
2018-03-30 11:31                 ` Sameera Deshpande
2018-03-30 12:18                   ` Sameera Deshpande
2018-04-09  8:36                     ` Sameera Deshpande
2018-07-31 11:50                       ` Sameera Deshpande

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=318513c3-9bee-6ef0-11cc-c7c43e5144a2@arm.com \
    --to=sudi.das@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    --cc=marcus.shawcroft@arm.com \
    --cc=nd@arm.com \
    --cc=ramana.gcc@googlemail.com \
    --cc=richard.earnshaw@arm.com \
    --cc=richard.sandiford@linaro.org \
    --cc=sameera.deshpande@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).