On Fri, May 10, 2024 at 04:50:10PM +0800, HAO CHEN GUI wrote: > Hi Richard, > Thanks for your comments. > > 在 2024/5/10 15:16, Richard Biener 写道: > > But if targets return sth < COSTS_N_INSNS (1) but > 0 this is now no > > longer meaningful. So shouldn't it instead be > > > > return cost > 0 ? cost : 1; > Yes, it's better. > > > > > ? Alternatively returning fractions of COSTS_N_INSNS (1) from set_src_cost > > is invalid and thus the target is at fault (I do think that making zero the > > unknown value is quite bad since that makes it impossible to have zero > > as cost represented). > > > > It seems the check is to aovid pattern_cost return zero (unknown), so the > > comment holds to pattern_cost the same (it returns an 'int' so the better > > exceptional value would have been -1, avoiding the compare). > But sometime it adds an insn cost. If the unknown cost is -1, the total cost > might be distorted.
*All* code using a cost will have to be inspected and possibly adjusted if you decide to use a different value for "unknown" than what we have had for ages. All other cost functions interacting with this one, too. Segher