diff options
| author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2014-10-30 23:46:50 +0000 | 
|---|---|---|
| committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2014-10-30 23:46:50 +0000 | 
| commit | 9f336c4ec5adb124c8d7b75be8bc5d2f02db119c (patch) | |
| tree | c7f9184ce965abc299920caface9fe3842bbc1f5 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 6cda0d7269188f9b21c6dfe19a6f32f8432918da (diff) | |
| download | bcm5719-llvm-9f336c4ec5adb124c8d7b75be8bc5d2f02db119c.tar.gz bcm5719-llvm-9f336c4ec5adb124c8d7b75be8bc5d2f02db119c.zip | |
[SelectionDAG] When scalarizing trunc, don't assert for legal operands.
r212242 introduced a legalizer hook, originally to let AArch64 widen
v1i{32,16,8} rather than scalarize, because the legalizer expected, when
scalarizing the result of a conversion operation, to already have
scalarized the operands.  On AArch64, v1i64 is legal, so that commit
ensured operations such as v1i32 = trunc v1i64 wouldn't assert.
It did that by choosing to widen v1 types whenever possible.  However,
v1i1 types, for which there's no legal widened type, would still trigger
the assert.
This commit fixes that, by only scalarizing a trunc's result when the
operand has already been scalarized, and introducing an extract_elt
otherwise.  
This is similar to r205625.
Fixes PR20777.
llvm-svn: 220937
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp | 18 | 
1 files changed, 17 insertions, 1 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index 68187dd0b8c..27f63d27823 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -237,7 +237,23 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_LOAD(LoadSDNode *N) {  SDValue DAGTypeLegalizer::ScalarizeVecRes_UnaryOp(SDNode *N) {    // Get the dest type - it doesn't always match the input type, e.g. int_to_fp.    EVT DestVT = N->getValueType(0).getVectorElementType(); -  SDValue Op = GetScalarizedVector(N->getOperand(0)); +  SDValue Op = N->getOperand(0); +  EVT OpVT = Op.getValueType(); +  SDLoc DL(N); +  // The result needs scalarizing, but it's not a given that the source does. +  // This is a workaround for targets where it's impossible to scalarize the +  // result of a conversion, because the source type is legal. +  // For instance, this happens on AArch64: v1i1 is illegal but v1i{8,16,32} +  // are widened to v8i8, v4i16, and v2i32, which is legal, because v1i64 is +  // legal and was not scalarized. +  // See the similar logic in ScalarizeVecRes_VSETCC +  if (getTypeAction(OpVT) == TargetLowering::TypeScalarizeVector) { +    Op = GetScalarizedVector(Op); +  } else { +    EVT VT = OpVT.getVectorElementType(); +    Op = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, Op, +                      DAG.getConstant(0, TLI.getVectorIdxTy())); +  }    return DAG.getNode(N->getOpcode(), SDLoc(N), DestVT, Op);  } | 

