[llvm-commits] PATCH: new Value::getThruSplat API

Chris Lattner clattner at apple.com
Fri Oct 29 21:34:22 PDT 2010


On Oct 29, 2010, at 7:28 PM, Nick Lewycky wrote:
> Which reminds me; your current patch doesn't handle vector ConstantAggregateZero.
> 
> Good catch! Updated patch attached.

Some random comments:

+  /// getThruSplat - This method returns the singular splat value held by this
+  /// value if it is a ConstantVector holding a splat, otherwise it returns
+  /// itself.

This description is confusing to me.  How about something like:

If the current value is a constant vector where all of the elements have the same value, return that value.  Otherwise, return the current value.

Also, the way it is used is confusing.  Why not name it "getSplatElement" and have it return null on failure?

+Value *Value::getThruSplat() {
+  switch (getValueID()) {

This would be more natural and elegant written with two dyncasts instead of a switch.  The premature optimization isn't worth it, and llvm at least will turn the two dyncasts into a switch anyway.

Otherwise, looks fine to me.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101029/53b6128d/attachment.html>


More information about the llvm-commits mailing list