Puzzle about default_latency in insn scheduling, please help

Amker.Cheng amker.cheng@gmail.com
Tue Aug 4 14:42:00 GMT 2009

Hi All:
   I'm studying instruction scheduling of gcc. there are some words
about default_lantency
in gcc internal document , which I don't understand. the words are :
There is an important difference between the old description and the automaton
 based pipeline description. The latency time is used for all
dependencies when we
 use the old description. In the automaton based pipeline description, the given
 latency time is only used for true dependencies. The cost of anti-dependencies
 is always zero and the cost of output dependencies is the difference between
 latency times of the producing and consuming insns (if the diference
 the cost is considered to be zero).
I am puzzled about why cost of anti-dependencies is zero. does it have
any reason
or advantage?

Further more, the mips target defined macro TARGET_SCHED_ADJUST_COST
as mips_adjust_cost, which assumes output-dependencies have no cost.

Now think about a tiny basic block like:
insn1  :  set1 r1, r2
insn2  :  set2 r1, r3
insn3  :  set3 r4, r1
the forward dependencies are like:
output-dep : <insn1, insn2>
true-dep : <insn1, insn3>, <insn2, insn3>
because the cost of output-dep is zero on mips, function insn_cost1  returns 0.
finally costs of insn computed by function priority will be:
cost(insn3) = defalut_latency(insn3)
cost(insn2) = default_latency(insn2) + cost(insn3)
cost(insn1) = default_latency(insn1) + cost(insn3)
Now  the scheduling order of insn1 and insn2 is depends on
default_lantency(insn1) > default_latency(insn2) or not.

there must be something wrong in my understanding, pelase help and any
tip will be appreciated.

Best Regards.

More information about the Gcc-help mailing list