public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Renlin Li <renlin.li@foss.arm.com>
To: Peter Bergner <bergner@linux.ibm.com>
Cc: Jeff Law <law@redhat.com>, Vladimir Makarov <vmakarov@redhat.com>,
	Christophe Lyon <christophe.lyon@linaro.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
	Kyrill Tkachov <kyrylo.tkachov@arm.com>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Subject: Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
Date: Thu, 08 Nov 2018 16:20:00 -0000	[thread overview]
Message-ID: <780be720-c80e-c45a-d56e-7265cd5174da@foss.arm.com> (raw)
In-Reply-To: <3f8c636b-06fd-8f64-ba00-00d7e8bdba54@linux.ibm.com>

Hi Peter,

On 11/08/2018 03:21 PM, Peter Bergner wrote:
> On 11/8/18 4:57 AM, Renlin Li wrote:
>> I think I found the problem!
>>
>> As described in the PR, a hard register is used in
>> an pre/post modify expression. The hard register is live, but updated.
>> In this case, we should make it conflicting with all pseudos live at
>> that point.  Does it make sense?
> [snip]
>> It fixes the ICE of mis-compiled arm-linux-gnueabihf toolchain described in the
>> PR.
>>
>> I attached the patch for discussion.  I haven't give a complete test on arm or
>> any other targets, yet. (Probably need more adjusting)
> 
> Yes, this is the problem.  We see from the dump, that r2040 does not conflict with
> hard reg r1:
> 
> ;; a2040(r1597,l0) conflicts: <list of pseudo regs>
> ;;     total conflict hard regs:
> ;;     conflict hard regs:
I think you should look for axxx(r2040, ..)?

Maybe I am wrong (not an expert of RA), from what I observed, it is the LRA
makes the code more complex. It decides to split the live range and spill r2040.
It creates multiple instructions to reload it.
r2944 in LRA dump is the register which starts to go wrong. It is assigned as r1.


       Creating newreg=2944 from oldreg=2040, assigning class GENERAL_REGS to inheritance r2944
     Original reg change 2040->2944 (bb2):
  10905: r1:SI=r2944:SI
     Add inheritance<-original before:
  12868: r2944:SI=r2040:SI

The dump is the final state of LRA. I debug it with gdb, and there are some temporary steps
which is not observable in the final dump.

> 
> ...and we have the following RTL:
> 
> (insn 10905 179 199 2 (set (reg:SI 1 r1)
>          (reg/f:SI 2040)) "../../gcc/gcc/vec.h":1654 647 {*thumb2_movsi_vfp}
>       (nil))
> 
> ...
> 
> (insn 208 202 182 2 (set (mem/f/c:SI (pre_modify:SI (reg:SI 1 r1)
>                  (plus:SI (reg:SI 1 r1)
>                      (const_int 12 [0xc]))) [129 loop_nest.m_vec+0 S4 A32])
>          (reg:SI 1048)) "../../gcc/gcc/vec.h":1654 647 {*thumb2_movsi_vfp}
>       (expr_list:REG_INC (reg:SI 1 r1)
>          (nil)))
> 
> ...
> 
> (insn 191 189 192 2 (set (mem/f/c:SI (plus:SI (reg/f:SI 2040)
>                  (const_int 8 [0x8])) [367 ddrs_table+0 S4 A32])
>          (reg/f:SI 1047)) "../../gcc/gcc/tree-loop-distribution.c":2741 647 {*thumb2_movsi_vfp}
>       (nil))
> 
> So my patch caused us to (correctly) skip adding a conflict between r1 and
> r2040 due to the register copy in insn 10905.  However, they really should
> conflict as you found due to the definition of r1 in insn 208 and the fact
> we don't add one is a latent bug in LRA.  I think your patch is on the right
> track, but not totally there yet.  Imagine instead that the references to r1
> and r2040 were swapped, so instead we have:
> 
> (insn 10905 179 199 2 (set (reg:SI 2040)
>          (reg/f:SI 1 r1)) "../../gcc/gcc/vec.h":1654 647 {*thumb2_movsi_vfp}
>       (nil))
> 
> ...
> 
> (insn 208 202 182 2 (set (mem/f/c:SI (pre_modify:SI (reg:SI 2040)
>                  (plus:SI (reg:SI 2040)
>                      (const_int 12 [0xc]))) [129 loop_nest.m_vec+0 S4 A32])
>          (reg:SI 1048)) "../../gcc/gcc/vec.h":1654 647 {*thumb2_movsi_vfp}
>       (expr_list:REG_INC (reg:SI 2040)
>          (nil)))
> 
> ...
> 
> (insn 191 189 192 2 (set (mem/f/c:SI (plus:SI (reg/f:SI 1 r1)
>                  (const_int 8 [0x8])) [367 ddrs_table+0 S4 A32])
>          (reg/f:SI 1047)) "../../gcc/gcc/tree-loop-distribution.c":2741 647 {*thumb2_movsi_vfp}
>       (nil))
> 
> Even with your patch, we'd miss adding the conflict between r1 and r2040.
> Let me think about how we should solve this one.

Yes, I am not confident the patch will be the ultimate fix to the problem.

> 
> And a *BIG* thank you for tracking down the problem!!!
> 
Nop.

Regards,
Renlin
> Peter
> 

  reply	other threads:[~2018-11-08 16:20 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 21:14 [PATCH 0/2][IRA,LRA] " Peter Bergner
2018-09-26 21:16 ` [PATCH 1/2][IRA,LRA] " Peter Bergner
2018-09-26 21:36 ` [PATCH 2/2][IRA,LRA] " Peter Bergner
2018-09-28 21:45 ` [PATCH 0/2][IRA,LRA] " Vladimir Makarov
2018-09-30 20:28   ` Peter Bergner
2018-10-01  0:57     ` H.J. Lu
2018-10-01  1:18       ` Peter Bergner
2018-10-01 12:46         ` H.J. Lu
2018-10-01 12:51           ` H.J. Lu
2018-10-01 13:16             ` H.J. Lu
2018-10-01 14:05               ` Peter Bergner
2018-10-02  4:08             ` Peter Bergner
2018-10-02 14:50               ` Jeff Law
2018-10-02 15:07               ` Peter Bergner
2018-10-02 15:37                 ` H.J. Lu
2018-10-02 15:55                   ` Peter Bergner
2018-10-02 17:14                     ` H.J. Lu
2018-10-02 21:53                 ` Peter Bergner
2018-10-02 22:28                   ` H.J. Lu
2018-10-03  0:35                     ` Peter Bergner
2018-10-03  2:23                       ` H.J. Lu
2018-10-03  2:46                         ` Peter Bergner
2018-10-03 14:43                 ` [PATCH 2/2 v3][IRA,LRA] " Peter Bergner
2018-10-04 22:18                   ` Vladimir Makarov
2018-10-05 16:50                     ` Peter Bergner
2018-10-05 18:54                       ` Vladimir Makarov
2018-10-05 20:10                         ` Peter Bergner
2018-10-05 22:56                           ` Vladimir Makarov
2018-10-06  6:40                             ` Peter Bergner
2018-10-08  9:37                               ` Christophe Lyon
2018-10-08 14:21                                 ` Peter Bergner
2018-10-08 14:46                                   ` Christophe Lyon
2018-10-08 15:04                                     ` Jeff Law
2018-10-11  2:57                                       ` Peter Bergner
2018-10-11 18:26                                         ` Peter Bergner
2018-10-11 20:31                                           ` Peter Bergner
2018-10-11 20:46                                             ` Jeff Law
2018-10-11 21:09                                               ` Peter Bergner
2018-10-11 21:36                                                 ` Jeff Law
2018-10-12  9:50                                                 ` Eric Botcazou
2018-10-11 21:05                                             ` Vladimir Makarov
2018-10-12 16:57                                               ` Peter Bergner
2018-10-12 17:56                                                 ` Jeff Law
2018-10-12  4:44                                             ` Jeff Law
2018-10-16  2:50                                               ` Peter Bergner
2018-11-01 18:50                                                 ` Renlin Li
2018-11-01 20:35                                                   ` Segher Boessenkool
2018-11-01 22:08                                                   ` Peter Bergner
2018-11-02 10:05                                                     ` Renlin Li
2018-11-05 19:20                                                     ` Jeff Law
2018-11-05 19:36                                                       ` Peter Bergner
2018-11-05 19:41                                                         ` Jeff Law
2018-11-06 10:52                                                           ` Renlin Li
2018-11-06 10:57                                                             ` Ramana Radhakrishnan
2018-11-06 12:23                                                               ` Renlin Li
2018-11-06 18:46                                                                 ` Peter Bergner
2018-11-06 18:58                                                             ` Jeff Law
2018-11-08 10:57                                                               ` Renlin Li
2018-11-08 11:49                                                                 ` Richard Biener
2018-11-08 14:29                                                                   ` Peter Bergner
2018-11-08 19:01                                                                     ` Peter Bergner
2018-11-08 12:35                                                                 ` Peter Bergner
2018-11-08 13:42                                                                   ` Renlin Li
2018-11-08 15:21                                                                 ` Peter Bergner
2018-11-08 16:20                                                                   ` Renlin Li [this message]
2018-11-08 17:52                                                                     ` Peter Bergner

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=780be720-c80e-c45a-d56e-7265cd5174da@foss.arm.com \
    --to=renlin.li@foss.arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=bergner@linux.ibm.com \
    --cc=christophe.lyon@linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kyrylo.tkachov@arm.com \
    --cc=law@redhat.com \
    --cc=segher@kernel.crashing.org \
    --cc=vmakarov@redhat.com \
    /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).