Right way to represent flag-setting arithmetic instructions in MD files

Segher Boessenkool segher@kernel.crashing.org
Fri Mar 10 23:57:00 GMT 2017


On Fri, Mar 10, 2017 at 10:30:33AM +0000, Kyrill Tkachov wrote:
> I'm trying to improve the cases where the result of the arithmetic
> operation is used in multiple places besides the comparison.
> For example:
>         add     w0, w0, w1
>         add     w1, w0, 2
>         cmp     w0, 0
> 
> Combine will not attempt to merge the first ADD and CMP because W0 is used
> in the second ADD.

So the LOG_LINK from the first instruction will point at the second,
and combining the first and the third isn't considered (because the
first and second insns don't combine).

combine doesn't try to combine all producer-consumer pairs, only
producer with first consumer, because it would not often help and
could easily take much more time.  On the other hand I'd love to get
rid of the LOG_LINKS and use DF directly.

Note that combining the first and third insns in your example requires
to put the combined insns in the place of the first insn, where
normally it would put it at the third insn.  Maybe we could treat
compares specially?

Do such cases happen a lot, btw?


Segher



More information about the Gcc mailing list