// Vector Result Scalarization: <1 x ty> -> ty.
void ScalarizeVectorResult(SDNode *N, unsigned OpNo);
SDValue ScalarizeVecRes_BinOp(SDNode *N);
+ SDValue ScalarizeVecRes_ShiftOp(SDNode *N);
SDValue ScalarizeVecRes_UnaryOp(SDNode *N);
SDValue ScalarizeVecRes_BIT_CONVERT(SDNode *N);
case ISD::UDIV:
case ISD::UREM:
case ISD::XOR: R = ScalarizeVecRes_BinOp(N); break;
+
+ case ISD::SHL:
+ case ISD::SRA:
+ case ISD::SRL: R = ScalarizeVecRes_ShiftOp(N); break;
}
// If R is null, the sub-method took care of registering the result.
return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, RHS);
}
+SDValue DAGTypeLegalizer::ScalarizeVecRes_ShiftOp(SDNode *N) {
+ SDValue LHS = GetScalarizedVector(N->getOperand(0));
+ SDValue ShiftAmt = GetScalarizedVector(N->getOperand(1));
+ if (TLI.getShiftAmountTy().bitsLT(ShiftAmt.getValueType()))
+ ShiftAmt = DAG.getNode(ISD::TRUNCATE, TLI.getShiftAmountTy(), ShiftAmt);
+ else if (TLI.getShiftAmountTy().bitsGT(ShiftAmt.getValueType()))
+ ShiftAmt = DAG.getNode(ISD::ANY_EXTEND, TLI.getShiftAmountTy(), ShiftAmt);
+
+ return DAG.getNode(N->getOpcode(), LHS.getValueType(), LHS, ShiftAmt);
+}
+
SDValue DAGTypeLegalizer::ScalarizeVecRes_BIT_CONVERT(SDNode *N) {
MVT NewVT = N->getValueType(0).getVectorElementType();
return DAG.getNode(ISD::BIT_CONVERT, NewVT, N->getOperand(0));
case ISD::AND:
case ISD::OR:
case ISD::XOR:
+ case ISD::SHL:
+ case ISD::SRA:
+ case ISD::SRL:
case ISD::UREM:
case ISD::SREM:
case ISD::FREM: SplitVecRes_BinOp(N, Lo, Hi); break;
--- /dev/null
+; RUN: llvm-as < %s | llc
+
+; Legalization test that requires scalarizing a vector.
+
+define void @update(<1 x i32> %val, <1 x i32>* %dst) nounwind {
+entry:
+ %shl = shl <1 x i32> %val, < i32 2>
+ %shr = ashr <1 x i32> %val, < i32 4>
+ store <1 x i32> %shr, <1 x i32>* %dst
+ ret void
+}
--- /dev/null
+; RUN: llvm-as < %s | llc
+
+; Legalization example that requires splitting a large vector into smaller pieces.
+
+define void @update(<8 x i32> %val, <8 x i32>* %dst) nounwind {
+entry:
+ %shl = shl <8 x i32> %val, < i32 2, i32 2, i32 2, i32 2, i32 4, i32 4, i32 4, i32 4 >
+ %shr = ashr <8 x i32> %val, < i32 2, i32 2, i32 2, i32 2, i32 4, i32 4, i32 4, i32 4 >
+ store <8 x i32> %shr, <8 x i32>* %dst
+ ret void
+}