[PATCH] D13655: DAGCombiner: Combine extract_vector_elt from build_vector

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 15:06:12 PDT 2015


RKSimon added inline comments.

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:11893
@@ +11892,3 @@
+       TLI.aggressivelyPreferBuildVectorSources(VT))) {
+    return InVec.getOperand(ConstEltNo->getZExtValue());
+  }
----------------
arsenm wrote:
> arsenm wrote:
> > RKSimon wrote:
> > > You may need to confirm that the operand value type is the same as the BUILD_VECTOR scalar value type - implicit truncation may be occurring.
> > Is this really supposed to be allowed? I would consider mismatched vector element and destination vector types to be a bug. The comment in getConstant made me very unhappy
> I also think this might be redundant with isTypeLegal on the element type. If this case is really allowed, I think it only happens if the scalar type is not legal and the vector is
Yes implicit truncation is permitted, a lot of the vector constant folding code has to deal with this. 

Integer scalar input bit widths can be larger than the vector type, although all the scalars must have the same type. Both types can be legal so the isTypeLegal() test isn't enough. 

You should be able to fold any constant truncation for free, but otherwise you will need a isTruncateFree test.


http://reviews.llvm.org/D13655





More information about the llvm-commits mailing list