[llvm-commits] [llvm] r160235 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/Generic/2012-07-15-BuildVectorPromote.ll
Duncan Sands
baldrick at free.fr
Mon Jul 16 05:28:27 PDT 2012
Hi Nadav, thanks for fixing this.
> Fix a bug in the scalarization of BUILD_VECTOR. BUILD_VECTOR elements may be wider than the output element type. Make sure to trunc them if needed.
>
> Together with Michael Kuperstein <michael.m.kuperstein at intel.com>
...
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Sun Jul 15 15:39:08 2012
> @@ -48,7 +48,7 @@
>
> case ISD::MERGE_VALUES: R = ScalarizeVecRes_MERGE_VALUES(N, ResNo);break;
> case ISD::BITCAST: R = ScalarizeVecRes_BITCAST(N); break;
> - case ISD::BUILD_VECTOR: R = N->getOperand(0); break;
> + case ISD::BUILD_VECTOR: R = ScalarizeVecRes_BUILD_VECTOR(N); break;
> case ISD::CONVERT_RNDSAT: R = ScalarizeVecRes_CONVERT_RNDSAT(N); break;
> case ISD::EXTRACT_SUBVECTOR: R = ScalarizeVecRes_EXTRACT_SUBVECTOR(N); break;
> case ISD::FP_ROUND: R = ScalarizeVecRes_FP_ROUND(N); break;
> @@ -152,6 +152,14 @@
> NewVT, N->getOperand(0));
> }
>
> +SDValue DAGTypeLegalizer::ScalarizeVecRes_BUILD_VECTOR(SDNode *N) {
> + EVT EltVT = N->getValueType(0).getVectorElementType();
> + SDValue InOp = N->getOperand(0);
> + if (InOp.getValueType() != EltVT)
This test is not actually needed since getNode will return InOp if there is no
actual truncation to be done. Also, how about adding a (brief) comment about
why truncation is needed.
> + return DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), EltVT, InOp);
> + return InOp;
> +}
> +
> SDValue DAGTypeLegalizer::ScalarizeVecRes_CONVERT_RNDSAT(SDNode *N) {
> EVT NewVT = N->getValueType(0).getVectorElementType();
> SDValue Op0 = GetScalarizedVector(N->getOperand(0));
Ciao, Duncan.
More information about the llvm-commits
mailing list