On 7/7/15 06:09, Chen Gang wrote:
> On 7/6/15 20:51, Bernd Schmidt wrote:
>> On 07/03/2015 04:13 AM, Chen Gang wrote:
>>>
>>> I shall continue to analyse why 2nd lsetup optimiation has not happened.
>>> Hope I can finish within next week (2015-07-12).
>>
>> I've committed my patch after testing bfin-elf. There's no great mystery why
>> the second optimization doesn't happen: the point where it thinks it has to
>> insert the LSETUP is after the loop, and the instruction doesn't allow that.
>> Possibly we could change that - when the loop is entered at the top but not
>> through a fallthrough edge, we could make a new block ahead of it and put
>> the LSETUP in there.
>>
After trying, for me, we need notice about the jump insn to loop start
label, and emit lsetup insn to loop head instead of incoming_src end,
the related diff is below:
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index a131053..9ef2a9c 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3416,6 +3416,7 @@ bfin_hardware_loop (void)
#define MAX_LOOP_LENGTH 2042
/* Maximum distance of the LSETUP instruction from the loop start. */
+/* #define MAX_LSETUP_DISTANCE 30 */
#define MAX_LSETUP_DISTANCE 30
/* Estimate the length of INSN conservatively. */
@@ -3456,7 +3457,7 @@ hwloop_optimize (hwloop_info loop)
rtx seq_end;
rtx_insn *seq;
int length;
- bool clobber0, clobber1;
+ bool clobber0, clobber1, direct_jmp = false;
if (loop->depth > MAX_LOOP_DEPTH)
{
@@ -3519,7 +3520,13 @@ hwloop_optimize (hwloop_info loop)
|| !(loop->incoming->last ()->flags & EDGE_FALLTHRU))
{
gcc_assert (JUMP_P (insn));
- insn = PREV_INSN (insn);
+ if (JUMP_LABEL (insn) != loop->start_label)
+ insn = PREV_INSN (insn);
+ else
+ {
+ direct_jmp = true;
+ insn = loop->start_label;
+ }
}
for (; insn && insn != loop->start_label; insn = NEXT_INSN (insn))
@@ -3783,7 +3790,7 @@ hwloop_optimize (hwloop_info loop)
seq = get_insns ();
end_sequence ();
- if (loop->incoming_src)
+ if (loop->incoming_src && !direct_jmp)
{
rtx_insn *prev = BB_END (loop->incoming_src);
if (vec_safe_length (loop->incoming) > 1
Welcome any additional ideas, suggestions and completions (and I shall
send patch for it, if no additional relply within the next week).
Thanks.
>
> OK, thanks. for me, the fix is enough for this issue. And need we add
> the related .i file to testsuite, too?
>
> And thank you for your information, I shall try to let 2nd times lsetup
> have effect in another patch, hope I can succeed :-).
>
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed