This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/6] ifcvt: Allow constants operands in noce_convert_multiple_sets.


On 11/15/18 4:34 AM, Robin Dapp wrote:
>> This may ultimately be too simplistic.  There are targets where some
>> constants are OK, but others may not be.   By checking the predicate
>> like this I think you can cause over-aggressive if-conversion if the
>> target allows a range of integers in the expander's operand predicate,
>> but allows a narrower range in the actual define_insn (presumably the
>> expander loads them into a pseudo or somesuch in that case).
>>
>> We know that over-aggressive if-conversion into conditional moves hurts
>> some targets.
>>
>> Ideally you'd create the actual insn with the constants you want to use
>> and see if that's recognized as well as compute its cost.  Is that just
>> too painful at this point for some reason?
> 
> Conditional moves in noce_convert_multiple_sets are processed via
> noce_emit_cmove which itself performs quite some preprocessing and calls
> optab's emit_conditional_move in the end, so the insn will already be
> emitted before being able to decide whether to decline it due to costs.
> In addition, every noce_emit_cmove will emit the condition check again
> as well as possible temporaries.
I wonder if we could arrange to emit them onto a new sequence.  We could
then cost the entire sequence.  If we end up wanting to do the
transformation we then splice that sequence into the main insn chain at
the appropriate place.

There should be a start/push/pop/end for sequences that you could use
for helpers.

> 
> Comparing the costs of the whole sequence will therefore still prove
> difficult as all the additionally generated insns will not get removed
> until reload and make a fair comparison nigh impossible.
You'd probably have to make an educated guess about what insns from the
original sequence would die and could therefore be removed.

> 
> I was reluctant to factor out all the preprocessing stuff, separate it
> from the condition check and actual emitting part but that's properly
> the "right way" to do it, including emitting the condition only once in
> the beginning.
If the push_to_sequence idea works you may not have to do a ton of
refactoring.  Essentially it changes where things like emit_insn and
friends splice in newly created insns.  It may allow you to leave most
of the current code in-place and you just have to splice in the sequence
at the end (there's a routine to help you with that too -- it's been a
long time, so the names aren't in memory anymore).


> 
> However, for now, I could imagine changing only the
> conversion_profitable_p hook in our backend to only count the cmovs and
> ignore everything else in the sequence.  This would be somewhat hacky
> though and still wouldn't allow constants :)
That does sound hacky..

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]