[llvm-commits] [llvm] r132892 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Duncan Sands baldrick at free.fr
Sun Jun 12 08:48:43 PDT 2011


Hi Nadav,

> Improve the generated code by getCopyFromPartsVector for promoted integer types.
> Instead of scalarizing, and doing an element-by-element truncat, use vector
> truncate.
> Add support for scalarization of vectors:  i8 ->  <1 x i1>  (from Duncan's
> testcase).

thanks for working on this.  What about getCopyToPartsVector?

> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Jun 12 09:49:38 2011
> @@ -310,9 +298,17 @@
>         TLI.isTypeLegal(ValueVT))
>       return DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
>
> -  assert(ValueVT.getVectorElementType() == PartVT&&
> -         ValueVT.getVectorNumElements() == 1&&
> +  // Handle cases such as i8 ->  <1 x i1>
> +  assert(ValueVT.getVectorNumElements() == 1&&
>            "Only trivial scalar-to-vector conversions should get here!");
> +
> +  if (ValueVT.getVectorNumElements() == 1&&

No need to test for ValueVT.getVectorNumElements() == 1; you just checked this
with an assertion.

> @@ -492,11 +488,14 @@
>                           &NewOps[0], NewOps.size());
>       } else{
>         // Vector ->  scalar conversion.
> -      assert(ValueVT.getVectorElementType() == PartVT&&
> -             ValueVT.getVectorNumElements() == 1&&
> +      assert(ValueVT.getVectorNumElements() == 1&&
>                "Only trivial vector-to-scalar conversions should get here!");
>         Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
>                           PartVT, Val, DAG.getIntPtrConstant(0));
> +
> +      bool Smaller = ValueVT.bitsLE(PartVT);
> +      Val = DAG.getNode((Smaller ? ISD::TRUNCATE : ISD::ANY_EXTEND),
> +                         DL, PartVT, Val);

As a micro-optimization, I suggest you only do this if
ValueVT.getVectorElementType() != PartVT.

Ciao, Duncan.



More information about the llvm-commits mailing list