This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/82683] Combine: GCC generates bad code with -tune=thunderx2t99
- From: "wilco at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Oct 2017 12:43:57 +0000
- Subject: [Bug rtl-optimization/82683] Combine: GCC generates bad code with -tune=thunderx2t99
- Auto-submitted: auto-generated
- References: <bug-82683-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82683
--- Comment #4 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #3)
> Ah. So we start with
>
> insn_cost 4 for 18: r91:DI=r83:DI<<0x2
> REG_DEAD r83:DI
> insn_cost 4 for 19: r78:DI=r76:DI+r91:DI
> REG_DEAD r91:DI
> REG_DEAD r76:DI
> insn_cost 20 for 20: r82:SI=[r78:DI]
> REG_DEAD r78:DI
> insn_cost 4 for 21: r83:DI=sign_extend(r82:SI)
>
> and first 18,19 are combined, and then 19,20,21. Both 19 and 21 set
> r83, it is dead after 19, but that note is put on 21.
Yes, it doesn't show intermediate stages but I guess before merging 18+19+20
with 21 we have:
r82:SI=MEM([r83:DI*0x4+r76:DI]) REG_DEAD r83
r83:DI=sign_extend r82:SI
This is correct. However when it merges these, it swaps r82 for r83 on the
load, and now the REG_DEAD in the load needs to be removed as it is no longer
valid:
r83:DI=sign_extend([r83:DI*0x4+r76:DI]) ***REG_DEAD r83***