[PATCH] D15816: [TTI] Add hook for contextual cast estimates

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 29 13:42:10 PST 2015

mssimpso created this revision.
mssimpso added reviewers: jmolloy, sbaranga, hfinkel.
mssimpso added subscribers: mcrosier, llvm-commits.
Herald added a subscriber: aemerson.

This change adds a new hook for estimating the cost of cast instructions within
a given context. The hook differs from the existing context-free hook in that
clients can provide information about the cast's known operand or user.

The change is motivated by sign extensions, which on AArch64 can often be
folded into other instructions and are free. For example, a vector extract
followed by a sign extension can be performed by smov. And a vector subtraction
whose operands are both vector sign extensions can be performed by ssubl. And
so on.

While context is generally not a desirable feature to include in the cost
model, the fact that these extensions are often free may make them special
enough to warrant the added complexity.

The default implementation of the hook uses the context-free estimate. For
AArch64, I've added logic to cover the extract-extend pattern and the
lengthening and widening operations I mentioned above. The intent is to quickly
and simply identify the cases in which the cast is free, and to fall back on
the default implementation otherwise.

For an initial client, I've modified the cast estimates in the SLP vectorizer
to provide the additional context when known and thought to be useful.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15816.43759.patch
Type: text/x-patch
Size: 17133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151229/d369a6af/attachment.bin>

More information about the llvm-commits mailing list