This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- From: Peter Bergner <bergner at linux dot ibm dot com>
- To: Renlin Li <renlin dot li at foss dot arm dot com>
- Cc: Jeff Law <law at redhat dot com>, Vladimir Makarov <vmakarov at redhat dot com>, Christophe Lyon <christophe dot lyon at linaro dot org>, gcc Patches <gcc-patches at gcc dot gnu dot org>, Segher Boessenkool <segher at kernel dot crashing dot org>, Ramana Radhakrishnan <Ramana dot Radhakrishnan at arm dot com>, Kyrill Tkachov <kyrylo dot tkachov at arm dot com>, Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Date: Thu, 8 Nov 2018 09:21:04 -0600
- Subject: Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- References: <db00fba8-f392-510f-7f75-31dd1eed6f87@linux.ibm.com> <CAKdteOY-WBs5qiDXUz-9ECb0JDat9pEhnu+t9m_N6_pyxd68rA@mail.gmail.com> <191bf9ee-98c4-b87e-cc65-40e1fb5de0ea@linux.ibm.com> <CAKdteOZy3BBGy5LW1Lf+sdhsLZtK08VEGNvwnZtBXoON6YuNJQ@mail.gmail.com> <c232f957-f5e1-ea5c-f5bf-77622f01f0e9@redhat.com> <bb4202ae-efae-9bc6-9bd4-7129f64c5992@linux.ibm.com> <478a817c-719b-9c3c-5b38-de7b277d9f93@linux.ibm.com> <13a249ee-160b-2b28-151c-bed3faacbfc1@linux.ibm.com> <0363139a-01af-b0eb-0941-111c1d7395b5@redhat.com> <f2c1737a-6323-214b-91bf-140e5fc983f5@linux.ibm.com> <3cdd23c9-5d07-c26d-9a10-42a4a9d6f77a@foss.arm.com> <b7518a7d-bdd6-679f-c077-89f044444b90@linux.ibm.com> <90073537-824d-697c-0ed8-9b611f9064c5@redhat.com> <e1646057-b120-dfe2-5cc3-8eb4eb19f84a@linux.ibm.com> <db5cb080-6b34-88a4-7c81-4d938006f843@redhat.com> <57966a2f-6dfd-7f10-266e-2732d0df6874@foss.arm.com> <576b4545-69b9-5418-1635-a2668b8e6613@redhat.com> <61550a92-b5d1-9b45-3401-3e7c96f98088@foss.arm.com>
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:
...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.
And a *BIG* thank you for tracking down the problem!!!
Peter
- References:
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register
- Re: [PATCH 2/2 v3][IRA,LRA] Fix PR86939, IRA incorrectly creates an interference between a pseudo register and a hard register