[llvm-commits] [llvm] r140471 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Duncan Sands baldrick at free.fr
Mon Sep 26 01:54:18 PDT 2011


Hi Nadav,

> [vector-select] Address one of the issues in pr10902. EXTRACT_VECTOR_ELEMENT
> SDNodes may return values which are wider than the incoming element types. In
> this patch we fix the integer promotion of these nodes.

> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Sun Sep 25 13:59:42 2011
> @@ -2987,8 +2987,13 @@
>     SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
>       V0->getValueType(0).getScalarType(), V0, V1);
>
> -  return DAG.getNode(ISD::TRUNCATE, dl, N->getValueType(0), Ext);
> -
> +  // EXTRACT_VECTOR_ELT can return types which are wider than the incoming
> +  // element types (see PromoteIntRes_EXTRACT_VECTOR_ELT). If this is the case

this is already explained in ISDOpcodes.h, so that would be a better place to
refer to.  But given that the very place that defines EXTRACT_VECTOR_ELT talks
about this, I think you can just drop the "(see XYZ") cross-reference.

> +  // then we need to expand the outgoing value and not truncate it.
> +  bool trunc = (N->getValueType(0).getSizeInBits()<
> +                Ext.getValueType().getSizeInBits());
> +  return DAG.getNode(trunc ? ISD::TRUNCATE : ISD::ANY_EXTEND,
> +                     dl, N->getValueType(0), Ext);

I suggest you add a method getAnyExtOrTrunc to go along with the existing
getSExtOrTrunc and getZExtOrTrunc methods, and use that instead.

Ciao, Duncan.



More information about the llvm-commits mailing list