This is the mail archive of the
mailing list for the GCC project.
RTL alternative selection question
- From: Andrew Stubbs <andrew_stubbs at mentor dot com>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Date: Mon, 23 Sep 2019 11:56:27 +0100
- Subject: RTL alternative selection question
- Ironport-sdr: LCC+wJGEyNuqhQT9BYKsMJ8UbiOX4fcypz2wcliFNiS8zC3CF7+xfZ6P6yR4EmYQC+iEqagsQC ulwi6n0OWQI0tYuKqetU+s/cXrGq4obNAtgdb9dXBm9yg9sHWIV4j9p9NpxwUZ21rM37RFKgHH vCEwSymm/Usnwtw+VnRood0Al3Ub7GpiECvnAzRV0PosCN/m89AYsOebOZf+R5k6ctNl1sRft0 lY7m68XrZCOVtxoM1UWgU6pHl/DiPa7o3+29SeHElXNW5RwOe9jCjAblFZ/wXzjlVBV8vcgSD5 Vuo=
- Ironport-sdr: nCsiI1faG7LxcwlMlNyz9Q0HwUBN/htqTztl4bc/NgGf0hoCBkYhCEPODSboSDANPTzG9/wCY6 g5Td5I4pzmNgUFrZ9RceMmS0wtEYKGkezboUw6RqWI8khbv0QmdMRBmPkcm1DqvLDnpz1BoLyr 2D0QrdUpmL/OrVN6a4NGrUy5aLSgE1XoP5+dLZI58uMqgRuyHoLo4tPpgY39eiHqNSaHSbjQ1f 5nfaqS5/VM+SCay5jLnVyJaMuWWVYj0gNr3z11TeaWGethOjGLZhpQANgMSGpuiEnkML/4mmOP Twk=
I'm trying to figure out how to prevent LRA selecting alternatives that
result in values being copied from A to B for one instruction, and then
immediately back from B to A again, when there are apparently more
sensible alternatives available.
I have an insn with the following pattern (simplified here):
[(set (match_operand:DI 0 "register_operand" "=Sg,v")
(match_operand:DI 1 "gcn_alu_operand" " Sg,v")
(match_operand:SI 2 "gcn_alu_operand" " Sg,v")))
(clobber (match_scratch:BI 3 "=cs,X"))]
There are two lshl instructions; one for scalar registers and one for
vector registers. The vector here has only a single element, so the two
are equivalent, but we need to pick one.
This operation works for both register files, but there are other
operations that exist only on one side or the other, so we want those to
determine in which register file the values are allocated.
Unfortunately, the compiler (almost?) exclusively selects the second
alternative, even when this means moving the values from one register
file to the other, and then back again.
The problem is that the scalar instruction clobbers the CC register,
which results in a "reject++" for that alternative in the LRA dump.
I can fix this by disparaging the second alternative in the pattern:
(clobber (match_scratch:BI 3 "=cs,?X"))
This appears to do the right thing. I can now see both kinds of shift
appearing in the assembly dumps.
But that does "reject+=6", which makes me worry that the balance has now
shifted too far the other way.
Does this make sense?
(clobber (match_scratch:BI 3 "=^cs,?X"))
Is there a better way to discourage the copies? Perhaps without editing
all the patterns?
What I want is for the two alternatives to appear equal when the CC
register is not live, and when CC is live for LRA to be able to choose
between reloading CC or switching to the other alternative according to
the situation, not on the pattern alone.
Thanks in advance.