[patch] RFC: Hook for insn costs?
Georg-Johann Lay
avr@gjlay.de
Wed Jul 12 13:15:00 GMT 2017
Hi,
the current cost computations in rtlanal.c and maybe other places
suffer from the fact that they are hiding parts of the expressions
from the back-end, like SET_DESTs of single_set or the anatomy of
PARALELLs.
Would it be in order to have a hook like the one attached?
I am aware of that, in an ideal world, there wouldn't be more
than one hook to get rtx costs. But well...
Whilst rtx_costs does in the majority of cases, there are cases
where hiding information leads to performance degradation,
for example when insn combine cooks up a set zero_extract.
combine.c does actually the right thing as it uses insn_rtx_costs,
but insn_rtx_cost is already a lie because it only uses SET_SRC
and digs into PARALELL without exposing the whole story.
The patch just uses a new targetm.insn_cost hook. If the
back-end doesn't come up with something useful, the classic
functions with rtx_costs for sub-rtxes are called.
The purpose is to allow a friendly transition and not no
raise any performance degradations which would be very likely
if we just called rtx_costs with outer_code = INSN.
If a back-end finds it useful to implement this hook and need
the whole story, they can do so. Otherwise, or if it is too
lazy to analyse a specific rtx, they can switch to the old
infrastructure.
Returning a magic value for "unknown" is just an implementation
detail; it could just as well be some bool* that would be set
to true or false depending on whether or not the computation
returned something useful or not.
The patch only touches seq_cost insn_rtx_cost of rtlanal.c.
Would something like this be in order, or is a new hook just
a complete no-go?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: insn-costs.diff
Type: text/x-patch
Size: 6810 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20170712/7f2245bd/attachment.bin>
More information about the Gcc
mailing list