Loop Vectorizer: Refactor Memory Cost Computation

Nadav Rotem nrotem at apple.com
Thu Feb 7 10:19:22 PST 2013


+        if (SI)
+          // In case of STORE, the cost of ExtractElement from the vector.
+          Cost += TTI.getVectorInstrCost(Instruction::ExtractElement, VectorTy,
+                                         i);
+        else
+          // In case of LOAD, the cost of InsertElement into the returned
+          // vector.
+          Cost += TTI.getVectorInstrCost(Instruction::InsertElement, VectorTy,
+                                         i);

Can be written as:

+          // In case of STORE, the cost of ExtractElement from the vector.
+          // In case of LOAD, the cost of InsertElement into the returned vector.
+          Cost += TTI.getVectorInstrCost(SI  ? Instruction::ExtractElement :  Instruction::InsertElement,
					VectorTy, i);

LGTM.   Thanks!



On Feb 7, 2013, at 10:15 AM, Arnold Schwaighofer <aschwaighofer at apple.com> wrote:

> As per feedback.
> 
> We don't want too many classes in a pass and the classes obscure the details. I
> was going a little overboard with object modeling here. Replace classes by
> generic code that handles both loads and stores.
> 
> <0001-Loop-Vectorizer-Refactor-Memory-Cost-Computation.patch>
> 
> Thanks,
> Arnold




More information about the llvm-commits mailing list