[PATCH] D31186: Changing TargetTransformInfo::getGEPCost to take GetElementPtrInst as parameter

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 11:03:05 PDT 2017


efriedma added a comment.

In some contexts, we might want to compute the cost of a GEP which doesn't actually exist in IR at the moment.  I guess there aren't any callers in the tree like that at the moment, but we use this sort of capability in other contexts, so we want to structure the code to allow it.

Actually, the inliner itself could in theory take advantage of that: if you have a function which returns a GEP, the cost depends on how the caller uses the value.  That might be overkill, though, given the tiny effect in most cases.

Along those lines, it probably makes sense to structure the code more like this:

1. The core cost function for GEPs should keep its existing signature, and just assume the GEP has users which are not memory operations (so it's not free unless all the indices are zero).
2. We should have a utility function which examines the users of the GEP, and checks if the GEP can be folded into them, using isLegalAddressingMode or something like that.



================
Comment at: include/llvm/Analysis/TargetTransformInfoImpl.h:571
                  ArrayRef<const Value *> Operands) {
+    assert(GEP);
+    const Value *Ptr = GEP->getPointerOperand();
----------------
Useless assertion/


https://reviews.llvm.org/D31186





More information about the llvm-commits mailing list