On 6/5/23 00:29, Richard Biener wrote:


But then for example x86 has smaller encoding for byte ops and while
widening is easily done later, truncation is not.
Which probably argues we need to be checking costs.


Btw, you failed to update the overall function comment which lists
the conversions applied.
ACK. It occurred to me when I woke up today that I also failed to handle the case where word_mode is actually smaller than an int.


Note I would have expected to use the mode of the load so we truly
elide some extensions, using word_mode looks like just another
mode here?  The key to note is probably

       op0 = convert_modes (mode, unit_mode, op0, 1);
       op1 = convert_modes (mode, unit_mode, op1, 1);
       rtx diff = expand_simple_binop (mode, MINUS, op0, op1,
                                       result, 1, OPTAB_WIDEN);
On many (most?) targets the loads can cheaply extend to word_mode.


which uses OPTAB_WIDEN - wouldn't it be better to pass in the
unconverted modes and leave the decision which mode to use
to OPTAB_WIDEN?  Should we somehow query the target for
the smallest mode from unit_mode it can do both the MINUS
and the compare?
I'll play with it. My worry is that the optabs are going to leave things in SImode. RV64 has 32 bit add/subtract which implicitly sign extends the result to 64 bits and Jivan's patch models that behavior with generally very good results. But again, I'll play with it.

I do agree that we need to be looking at cost modeling more in here. So I'll poke at that too.


jeff

Reply via email to