[PATCH] D30649: [SLP] Function for instruction cost calculation, NFC.

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 11:17:52 PST 2017


mkuper added a comment.

This makes sense. Some minor comments inline.



================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:420
+  /// VecTy are specified).
+  Optional<int> getCostOrDiff(unsigned Opcode, ArrayRef<Value *> VL,
+                              Type *ScalarTy, Type *VecTy = nullptr) const;
----------------
ABataev wrote:
> mkuper wrote:
> > This seems like a weird interface, for a couple of reasons:
> > 
> > 1) It's somewhat vague - I'd expect different APIs to get a cost and to get the diffs.
> > 2) It returns an Optional, but none of the uses actually check the returned value is valid. And when would you expect to return None anyway? Shouldn't we recognize any instruction here? If not, then do we expect to assert, or just silently decide the instruction will be scalarized?
> > 3) Only the Call case actually wants the scalar and the vector costs separately, and I don't really understand why - it ends up subtracting them.
> > 
> > Splitting out a function that takes the vector and scalar type, and returns the difference, instead of having the subtraction repeated in every case, doesn't sound like a bad idea. Can you explain why this is an improvement over that, though?
> Michael, I reworked it. It is required for another path I'm going to publish today.
This still doesn't explain under what conditions it makes sense to return a None cost.
Does it mean "we don't know"? Something else?


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:1850
+  case Instruction::ShuffleVector: {
+    TargetTransformInfo::OperandValueKind Op1VK =
+        TargetTransformInfo::OK_AnyValue;
----------------
Any reason the shuffle case can't live with the rest in getCost()?
(The other special cases here are really special, but this seems pretty standard - it doesn't seem to use any extra information, only the VL)


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:1884
+      return Cost.getValue();
+    break;
   }
----------------
Why not put the llvm_unreachable here? I think it'd be clearer.


https://reviews.llvm.org/D30649





More information about the llvm-commits mailing list