[PATCH] Loop Vectorizer: Refactor code to compute vectorized memory instruction cost
Renato Golin
renato.golin at linaro.org
Mon Feb 4 07:22:44 PST 2013
Hi Arnold,
I like the approach, and I think we could do the same for all types of
instructions, not just load.
Regarding this specific code, I have some comments...
1. You seem to be cramming load & stores with a lot of non-shared code.
Maybe it'd be more efficient to have a MemoryCostComp that both
LoadCostComp and StoreCostComp derive and implement the specific parts.
2. Assert Liberally!
+ // It better be a load now.
+ Load = cast<LoadInst>(MemInst);
to
+ Load = dyn_cast<LoadInst>(MemInst);
+ assert(Load && "Invalid memory instruction type");
or use llvm_unreachable().
3. All this can be omitted if you use Instr* instead of specific
LoadInst/StoreInst and if you common up code in a base class:
+ unsigned getOpcode() {
+ if (Store)
+ return Store->getOpcode();
+
+ return Load->getOpcode();
+ }
+
+ unsigned getAlignment() {
+ if (Store)
+ return Store->getAlignment();
+
+ return Load->getAlignment();
+ }
+
+ unsigned getPointerAddressSpace() {
+ if (Store)
+ return Store->getPointerAddressSpace();
+
+ return Load->getPointerAddressSpace();
+ }
cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130204/664ade84/attachment.html>
More information about the llvm-commits
mailing list