[PATCH] D14730: [Aarch64] Add zero cost for extensions that may be eliminated.

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 08:03:51 PST 2015


mssimpso added a comment.

Hi Silviu,

Thanks very much for the feedback. I appreciate the counterexample. To be
clear, I'm not suggesting that these casts can always be eliminated. As you
mention that requires more context.

However, I do think that modeling these particular casts with zero (or near
zero) cost is probably more accurate for the majority of cases than the current
values. If I'm reading the intent of the current heuristics correctly, even in
your counterexample, the expected cost for the zext should be 2 (the number of
shift instructions) whereas the current cost model calculates a cost of 44.

I don't think the intent of the cost model is to predict with complete accuracy
the sequence of instructions the backend will select, but we should produce
reasonable values for common cases. I think that a zero (or near zero) cost for
these casts is the more reasonable value.

Having said that, we can certainly detect the interesting patterns in SLP and
other transformations with additional cost hooks. But I worry that this would
add unneeded complexity.

Since the casts in question aren't always guaranteed to be eliminated (but
often are), would you be opposed to giving them a near zero cost instead? I
think that would still be preferable to the current situation.


http://reviews.llvm.org/D14730





More information about the llvm-commits mailing list