[AArch64] Use type-legalization cost for code size memop cost.
authorFlorian Hahn <flo@fhahn.com>
Thu, 15 Apr 2021 08:22:32 +0000 (09:22 +0100)
committerFlorian Hahn <flo@fhahn.com>
Thu, 15 Apr 2021 09:11:05 +0000 (10:11 +0100)
commitacd9cc74957ba63967015946fc3349988ab200b1
treef4054122a15a3b27e3d9e32a2e874fbc3bfa005c
parent71a45e7c63285614364d3d5dfcb4d48da6e7535d
[AArch64] Use type-legalization cost for code size memop cost.

At the moment, getMemoryOpCost returns 1 for all inputs if CostKind is
CodeSize or SizeAndLatency. This fools LoopUnroll into thinking memory
operations on large vectors have a cost of one, even if they will get
expanded to a large number of memory operations in the backend.

This patch updates getMemoryOpCost to return the cost for the type
legalization for both CodeSize and SizeAndLatency. This should more
accurately reflect the number of memory operations required.

I am not sure how latency should properly be included in SizeAndLatency
from the description, but returning the size cost should be clearly more
accurate.

This does not cause any binary changes when building
MultiSource/SPEC2000/SPEC2006 with -O3 -flto for AArch64, likely because
large vector memops are not really formed by code emitted from Clang.
But using the C/C++ matrix extension can easily result in code with very
large vector operations directly from Clang, e.g.
https://clang.godbolt.org/z/6xzxcTGvb

Reviewed By: samparker

Differential Revision: https://reviews.llvm.org/D100291
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/AArch64/store.ll
llvm/test/Transforms/LoopUnroll/AArch64/large-vector-ops.ll