diff options
| author | Duncan Sands <baldrick@free.fr> | 2008-11-08 18:26:48 +0000 | 
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2008-11-08 18:26:48 +0000 | 
| commit | 0f3937115d8289f5cea6991e35fed83c5d86a3bb (patch) | |
| tree | 9d14db61859dc5b9e9f6a3670afe1bc77342e68c /llvm/lib/CodeGen | |
| parent | 09f51d1fd4b54ccbb9cd454db937b056785601de (diff) | |
| download | bcm5719-llvm-0f3937115d8289f5cea6991e35fed83c5d86a3bb.tar.gz bcm5719-llvm-0f3937115d8289f5cea6991e35fed83c5d86a3bb.zip | |
Try to produce better code when scalarizing VSETCC.
llvm-svn: 58920
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp | 34 | 
1 files changed, 26 insertions, 8 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index cfb85fd9849..2378798267a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -181,16 +181,34 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N) {  }  SDValue DAGTypeLegalizer::ScalarizeVecRes_VSETCC(SDNode *N) { -  MVT NewVT = N->getValueType(0).getVectorElementType();    SDValue LHS = GetScalarizedVector(N->getOperand(0));    SDValue RHS = GetScalarizedVector(N->getOperand(1)); -  LHS = DAG.getNode(ISD::SETCC, TLI.getSetCCResultType(LHS), LHS, RHS, -                    N->getOperand(2)); -  return -    DAG.getNode(ISD::SELECT, NewVT, LHS, -                DAG.getConstant(APInt::getAllOnesValue(NewVT.getSizeInBits()), -                                NewVT), -                DAG.getConstant(0ULL, NewVT)); +  MVT NVT = N->getValueType(0).getVectorElementType(); +  MVT SVT = TLI.getSetCCResultType(LHS); + +  // Turn it into a scalar SETCC. +  SDValue Res = DAG.getNode(ISD::SETCC, SVT, LHS, RHS, N->getOperand(2)); + +  // VSETCC always returns a sign-extended value, while SETCC may not.  The +  // SETCC result type may not match the vector element type.  Correct these. +  if (NVT.getSizeInBits() <= SVT.getSizeInBits()) { +    // The SETCC result type is bigger than the vector element type. +    // Ensure the SETCC result is sign-extended. +    if (TLI.getSetCCResultContents() != +        TargetLowering::ZeroOrNegativeOneSetCCResult) +      Res = DAG.getNode(ISD::SIGN_EXTEND_INREG, SVT, Res, +                        DAG.getValueType(MVT::i1)); +    // Truncate to the final type. +    return DAG.getNode(ISD::TRUNCATE, NVT, Res); +  } else { +    // The SETCC result type is smaller than the vector element type. +    // If the SetCC result is not sign-extended, chop it down to MVT::i1. +    if (TLI.getSetCCResultContents() != +        TargetLowering::ZeroOrNegativeOneSetCCResult) +      Res = DAG.getNode(ISD::TRUNCATE, MVT::i1, Res); +    // Sign extend to the final type. +    return DAG.getNode(ISD::SIGN_EXTEND, NVT, Res); +  }  } | 

