On 10/30/19 2:12 AM, Richard Biener wrote:
> On Tue, Oct 29, 2019 at 8:34 PM Jeff Law <l...@redhat.com> wrote:

> 
> I think the wiki has better examples.  That said, I wonder how much can
> be automated here, for example when just considering CCmode (m68k has
> setcc IIRC) then for example all define_insns like
> 
> (define_insn "*cmpsi_cf"
>   [(set (cc0)
>         (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
>                  (match_operand:SI 1 "general_operand" "r,mrKs")))]
>   "TARGET_COLDFIRE"
> {...}
The compare/test insns are relatively straightforward as they're a
fairly simple substitution.  It's all the other insns that implicitly
set cc0 that are so painful.


> 
> The various expanders need to be handled manually I guess, though somehow
> automagically generating the define_insn_and_split might be possible
> as well, no?
I was looking at define_subst to help here, but it didn't look like it
was really going to simplify things in any significant way.  Maybe
someone with more experience with define_subst would see something that
would dramtically simplify this process.

> 
> That is, the work is quite repetitive (looking at m68k.md) and for this reason
> error-prone.  But a case#2 conversion could essentially be automated?
It's a case2.  ANd yes, it's highly repetitive.  That's the part of the
v850 conversion my son did.  Once he had all the mechanical stuff in
place I started banging it into shape.

> 
> That is, do you see it as impossible to implement a case#2 cc0 "conversion"
> in gen*?
I'd be surprised if it could be that simple.

> 
>> Some have claimed this might be easier with define_subst, but I wandered
>> it a bit and it didn't seem necessarily simpler in the end.  But maybe
>> someone with more experience with define_subst could make the transition
>> simpler.
>>
>> Anyway, that has to be done for each and every pattern that modifies the
>> condition codes.  It's a ton of mechanical work.  The m68k has the
>> additional complication that condition codes can be either in cc0 or
>> fcc0.  So that has to be taken into account as well.
> 
> I don't see that it does this currently though (cc0 doesn't allow this).
You're right.  fcmp seems to just set the normal condition codes, just
using a different insn.  So the FP unit shouldn't be a major problem.

> 
>> You also have to rewrite the tst/cmp and conditional branching patterns
>> to use the new style.
>>
>> Sadly until you do *all* of that you don't have anything you can really
>> test.  And even once you've done all that, the code quality is going to
>> suffer because we're not doing any compare/tst elimination.  To enable
>> that you have to go back and start adding patterns like this:
> 
> For m68k what helps is that you could concentrate on TARGET_COLDFIRE
> (or !TARGET_COLDFIRE).  Maybe even split m68k.md along this.
> 
> A lot of the define_insns also look like optimization (so could be disabled
> for the moment).
That's certainly how I'd approach it.  Disable everything not strictly
needed, convert what has to be converted, then bring back the patterns
incrementally.

Jeff

Reply via email to