[llvm-dev] TargetTransformInfo getOperationCost uses

Arsenault, Matthew via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 5 08:25:46 PST 2016


Hi,


I'm trying to implement the TTI hooks for AMDGPU to avoid unrolling loops for operations with huge expansions (i.e. integer division).


The values that are ultimately reported by opt -cost-model -analyze (the actual cost model tests) seem to not matter for this. The huge cost I've assigned division doesn't prevent the loop from being unrolled, because it isn't actually considered when loop unrolling.


The loop unrolled uses CodeMetrics, which via getUserCost ultimately uses TargetTransformInfoImplBase::getOperationCost(), which returns various fixed values (4 for division (TCC_Expensive, but this isn't nearly expensive enough)).


getOperationCost only uses the type and opcode to estimate, so it doesn't require a value. No target overrides this. The hooks that targets do really implement, like getArithmeticInstrCost, use some information about the operands so require a value. These don't appear to be used at all by the cost model, and instead in specific places in some passes.


Why don't any targets override getOperationCost or why aren't there any other hooks that change its behavior? Having these two parallel path for operation costs is confusing, especially since I expected to be able to use the -cost-model output for testing all of the computed costs.


-Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160105/e57e98d7/attachment.html>


More information about the llvm-dev mailing list