> On Oct 5, 2017, at 11:28 PM, Alexander Monakov <amona...@ispras.ru> wrote:
> 
> On Thu, 5 Oct 2017, Maxim Kuvyrkov wrote:
>> I'm still working on analysis, but it appears to me that Alexander's patch
>> (current state of trunk) fails qsort check due to not being symmetric for
>> load/store analysis (write == 0 or write == 1) in comparisons with
>> "irrelevant" instructions.  Wilco's patch does not seem to address that, and,
>> possibly, makes the failure latent (I may be wrong here, it's late and I
>> didn't finish analysis yet).
> 
> Yes, your analysis is incomplete, it should be easy to see that for 
> always-false
> multi_mem_insn_p, autopref_rank_for_schedule implements lexicographical order.
> The problem is that when multi_mem_insn_p may be true, autopref_rank_data is
> not guaranteed to be transitive.

Agree.

> 
> I think your patch loses transitivity in autopref_rank_for_schedule, see 
> Wilco's
> response.

Agree.

> 
> FWIW, this hunk from my patch posted back on Friday is sufficient to restore
> bootstrap as confirmed (again, back on Friday) by Steve.  It avoids the fancy
> non-transitive comparison for qsort (but autopref_rank_data is still used in
> multipref_dfa_lookahead_guard).
> 
> (I'm surprised Kyrill wasn't Cc'ed - adding him now)
> 
> Alexander
> 
>       * haifa-sched.c (autopref_rank_for_schedule): Do not invoke
>       autopref_rank_data, order by min_offset.
> 
> diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
> index 549e8961411..cea1242e1f1 100644
> --- a/gcc/haifa-sched.c
> +++ b/gcc/haifa-sched.c
> @@ -5725,7 +5669,7 @@ autopref_rank_for_schedule (const rtx_insn *insn1, 
> const rtx_insn *insn2)
>       int irrel2 = data2->status == AUTOPREF_MULTIPASS_DATA_IRRELEVANT;
> 
>       if (!irrel1 && !irrel2)
> -     r = autopref_rank_data (data1, data2);
> +     r = data1->min_offset - data2->min_offset;
>       else
>       r = irrel2 - irrel1;
>     }

I think that this is the best solution so far.  Could you add a comment like 
the following?
==
Ideally, we would call autopref_rank_data() here, but we can't since it is not 
guaranteed to return transitive results fro multi_mem_insns.  We use an 
approximation here and rely on lookahead_guard below to force instruction order 
according to autopref_rank_data().
==

I think that the above patch qualifies as obvious to unbreak the bootstrap.  
Wilco, any objection to the above fix?

Regards,

--
Maxim Kuvyrkov
www.linaro.org





Reply via email to