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

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 15:46:45 PST 2016


mssimpso marked 2 inline comments as done.

================
Comment at: include/llvm/Analysis/TargetTransformInfo.h:468
@@ -440,3 +467,3 @@
 
   /// \return The expected cost of control-flow related instructions such as
   /// Phi, Ret, Br.
----------------
I agree this seems overly complex. However, I'm having difficulty coming up with a better alternative.

For the scalar cost estimates (where we're getting an estimate for an instruction that already exists), I definitely see the advantage of just looking at the existing Values. We wouldn't have to re-encode the use-def information like you mention. But I think this gets trickier for the vector estimates. For example, considering the extract-extend case (where we sign extend the value we extract from the vector), we would need to create an unlinked instruction for the extract if I understand correctly. But what would it's operand be? We haven't decided to vectorize anything yet. And if we eventually chose not to vectorize, we would have to go back and delete the unlinked instructions we create. I'm definitely open to suggestions here, and any more thoughts you might have would be very helpful!

================
Comment at: include/llvm/Analysis/TargetTransformInfo.h:495
@@ -467,3 +494,3 @@
   /// \p Alignment - alignment of single element
   int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
                              bool VariableMask, unsigned Alignment) const;
----------------
I'm fine doing this. I've added an optional Ctx argument to the existing getCastInstrCost hook like you suggested. The drawback of course is that we have to modify the other targets (and we might cause some minor annoyance for the out-of-tree target maintainers).


http://reviews.llvm.org/D15816





More information about the llvm-commits mailing list