public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@cambridge.arm.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: target/7856: [arm] invalid offset in constant pool reference Date: Mon, 09 Sep 2002 07:16:00 -0000 [thread overview] Message-ID: <20020909141601.31865.qmail@sources.redhat.com> (raw) The following reply was made to PR target/7856; it has been noted by GNATS. From: Richard Earnshaw <rearnsha@cambridge.arm.com> To: gcc-gnats@gcc.gnu.org Cc: Richard.Earnshaw@arm.com Subject: Re: target/7856: [arm] invalid offset in constant pool reference Date: Mon, 09 Sep 2002 15:12:33 +0100 stupid gnats setup... ------- Forwarded Message Date: Mon, 09 Sep 2002 14:56:39 +0100 From: Richard Earnshaw <rearnsha@arm.com> To: Philip Blundell <pb@nexus.co.uk> cc: rearnsha@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nickc@redhat.com, nobody@gcc.gnu.org, rearnsha@arm.com Subject: Re: target/7856: [arm] invalid offset in constant pool reference > On Mon, 2002-09-09 at 11:56, rearnsha@gcc.gnu.org wrote: > > However, I'm not yet convinced that Nick's change is for the > > best overall. > > Well, mmm, it's tricky to know which gives you better code on average. > XScale makes it worse, because the penalty for using ldm/stm is greater > on those devices - you pay something like a two-cycle startup cost, plus > one cycle for every register transferred. So pushing LR unnecessarily > could cost you three cycles at entry and the same at exit, if you only > had one other register to save. > > Presumably we could avoid the particular problem at hand by making > use_return_insn() detect this situation - it already does this for > interworking, which is the other main case where > output_return_instruction would generate a 2-instruction sequence. Ok, lets try a bit more detailed analysis: For XScale: scenario 1: b<cond> return_seqence @ cost 5/1 (predict NOT taken) return_sequence: ldr sl, [sp], #4 @ cost 1 bx lr @ cost 5 Condition true Total = 11 cycles Condition false total = 1 cycle Scenario 2: ldr<cond> sl, [sp], #4 @ cost 1/1 bx<cond> lr @ cost 5/1 Condition true total = 6 cycles Condition false total = 2 cycles Scenario 3: ldm<cond> sp!, {sl, pc} @ cost 9/2? (Not sure on no-exec cost) Condition true total = 9 cycles Condition false total = 2 cycles For arm10 Scenario 1: b<cond> return_sequence @ cost 4/0 (predict NOT taken) return_sequence: ldr sl, [sp], #4 @ cost 1 bx lr @ cost 4 Condition true total = 9 cycles Condition flase total = 0 cycle Scenario 2: ldr<cond> sl, [sp], #4 @ cost 1/1 bx<cond> lr @ cost 4/2 Condition true total = 5 cycles Condition false total = 3 cycles Scenario 3: ldm<cond> sp!, {sl, pc} @ cost 7/2 Condition true total = 7 cycles Condition false total = 2 cycles For arm9e Scenario 1: b<cond> return_sequence @ cost 3/1 return_sequence: ldr sl, [sp], #4 @ cost 1 bx lr @ cost 3 Condition true total = 7 cycles Condition flase total = 1 cycle Scenario 2: ldr<cond> sl, [sp], #4 @ cost 1/1 bx<cond> lr @ cost 3/1 Condition true total = 4 cycles Condition false total = 2 cycles Scenario 3: ldm<cond> sp!, {sl, pc} @ cost 6/1 Condition true total = 6 cycles Condition false total = 1 cycles For arm7tdmi Scenario 1: b<cond> return_sequence @ cost 3/1 return_sequence: ldr sl, [sp], #4 @ cost 3 bx lr @ cost 3 Condition true total = 9 cycles Condition flase total = 1 cycle Scenario 2: ldr<cond> sl, [sp], #4 @ cost 3/1 bx<cond> lr @ cost 3/1 Condition true total = 6 cycles Condition false total = 2 cycles Scenario 3: ldm<cond> sp!, {sl, pc} @ cost 6/1 Condition true total = 6 cycles Condition false total = 1 cycles So it's fairly clear from this, that with the possible exception of the 7tdmi, we do not want to use an ldm instruction. Now for both arm10 and XScale, where branch prediction starts to kick in, it's also clear that we want to use a branch instruction instead of a conditionally executed exit sequence; this is particularly so inside a loop when we would like to benefit from the branch predictor eliminating the branch entirely. However, this does increase the cost of returning quite significantly in all cases. It's also fairly clear that scenario 2 is almost never the 'best' sequence (except when we think a conditional return is very likely). So I think the conclusion from all this is that we should make use_return_insn () return false whenever a return sequence would be ldr <reg> followed by a mov pc, lr. We should probably still allow an unconditional return sequence to be up to two instructions long (I don't think there's much to be gained from allowing it to be longer), and we should then adjust the length attribute of the "return" insn to be 8 (currently 4) to indicate the longest sequence possible (we could make it more accurate if we really needed, but there seems to be little point). R. ------- End of Forwarded Message
next reply other threads:[~2002-09-09 14:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-09-09 7:16 Richard Earnshaw [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-11-01 7:00 rearnsha 2002-09-09 3:56 rearnsha 2002-09-08 6:46 pb
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=20020909141601.31865.qmail@sources.redhat.com \ --to=rearnsha@cambridge.arm.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.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: linkBe 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).