mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-09 16:45:03 +00:00
[VECTOR-SELECT]
During type legalization we often use the SIGN_EXTEND_INREG SDNode. When this SDNode is legalized during the LegalizeVector phase, it is scalarized because non-simple types are automatically marked to be expanded. In this patch we add support for lowering SIGN_EXTEND_INREG manually. This fixes CodeGen/X86/vec_sext.ll when running with the '-promote-elements' flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135144 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aeb86fab3e
commit
d0f3ef807e
@ -182,9 +182,9 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
|
||||
case ISD::FRINT:
|
||||
case ISD::FNEARBYINT:
|
||||
case ISD::FFLOOR:
|
||||
case ISD::SIGN_EXTEND_INREG:
|
||||
QueryType = Node->getValueType(0);
|
||||
break;
|
||||
case ISD::SIGN_EXTEND_INREG:
|
||||
case ISD::FP_ROUND_INREG:
|
||||
QueryType = cast<VTSDNode>(Node->getOperand(1))->getVT();
|
||||
break;
|
||||
|
@ -1063,6 +1063,14 @@ X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SIGN_EXTEND_INREGs are evaluated by the extend type. Handle the expansion
|
||||
// of this type with custom code.
|
||||
for (unsigned VT = (unsigned)MVT::FIRST_VECTOR_VALUETYPE;
|
||||
VT != (unsigned)MVT::LAST_VECTOR_VALUETYPE; VT++) {
|
||||
setOperationAction(ISD::SIGN_EXTEND_INREG, (MVT::SimpleValueType)VT, Custom);
|
||||
}
|
||||
|
||||
// We want to custom lower some of our intrinsics.
|
||||
setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
|
||||
|
||||
@ -8928,8 +8936,8 @@ SDValue X86TargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG) const {
|
||||
}
|
||||
|
||||
// Lower SHL with variable shift amount.
|
||||
// Cannot lower SHL without SSE4.1 or later.
|
||||
if (!Subtarget->hasSSE41()) return SDValue();
|
||||
// Cannot lower SHL without SSE2 or later.
|
||||
if (!Subtarget->hasSSE2()) return SDValue();
|
||||
|
||||
if (VT == MVT::v4i32 && Op->getOpcode() == ISD::SHL) {
|
||||
Op = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT,
|
||||
@ -9076,6 +9084,58 @@ SDValue X86TargetLowering::LowerXALUO(SDValue Op, SelectionDAG &DAG) const {
|
||||
return Sum;
|
||||
}
|
||||
|
||||
SDValue X86TargetLowering::LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const{
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
SDNode* Node = Op.getNode();
|
||||
EVT ExtraVT = cast<VTSDNode>(Node->getOperand(1))->getVT();
|
||||
EVT VT = Node->getValueType(0);
|
||||
|
||||
if (Subtarget->hasSSE2() && VT.isVector()) {
|
||||
unsigned BitsDiff = VT.getScalarType().getSizeInBits() -
|
||||
ExtraVT.getScalarType().getSizeInBits();
|
||||
SDValue ShAmt = DAG.getConstant(BitsDiff, MVT::i32);
|
||||
|
||||
unsigned SHLIntrinsicsID = 0;
|
||||
unsigned SRAIntrinsicsID = 0;
|
||||
switch (VT.getSimpleVT().SimpleTy) {
|
||||
default:
|
||||
return SDValue();
|
||||
case MVT::v2i64: {
|
||||
SHLIntrinsicsID = Intrinsic::x86_sse2_pslli_q;
|
||||
SRAIntrinsicsID = 0;
|
||||
break;
|
||||
}
|
||||
case MVT::v4i32: {
|
||||
SHLIntrinsicsID = Intrinsic::x86_sse2_pslli_d;
|
||||
SRAIntrinsicsID = Intrinsic::x86_sse2_psrai_d;
|
||||
break;
|
||||
}
|
||||
case MVT::v8i16: {
|
||||
SHLIntrinsicsID = Intrinsic::x86_sse2_pslli_w;
|
||||
SRAIntrinsicsID = Intrinsic::x86_sse2_psrai_w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SDValue Tmp1 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT,
|
||||
DAG.getConstant(SHLIntrinsicsID, MVT::i32),
|
||||
Node->getOperand(0), ShAmt);
|
||||
|
||||
// In case of 1 bit sext, no need to shr
|
||||
if (ExtraVT.getScalarType().getSizeInBits() == 1) return Tmp1;
|
||||
|
||||
if (SRAIntrinsicsID) {
|
||||
Tmp1 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT,
|
||||
DAG.getConstant(SRAIntrinsicsID, MVT::i32),
|
||||
Tmp1, ShAmt);
|
||||
}
|
||||
return Tmp1;
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
|
||||
SDValue X86TargetLowering::LowerMEMBARRIER(SDValue Op, SelectionDAG &DAG) const{
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
|
||||
@ -9238,6 +9298,7 @@ static SDValue LowerADDC_ADDE_SUBC_SUBE(SDValue Op, SelectionDAG &DAG) {
|
||||
SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
||||
switch (Op.getOpcode()) {
|
||||
default: llvm_unreachable("Should not custom lower this!");
|
||||
case ISD::SIGN_EXTEND_INREG: return LowerSIGN_EXTEND_INREG(Op,DAG);
|
||||
case ISD::MEMBARRIER: return LowerMEMBARRIER(Op,DAG);
|
||||
case ISD::ATOMIC_CMP_SWAP: return LowerCMP_SWAP(Op,DAG);
|
||||
case ISD::ATOMIC_LOAD_SUB: return LowerLOAD_SUB(Op,DAG);
|
||||
@ -9336,6 +9397,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
|
||||
default:
|
||||
assert(false && "Do not know how to custom type legalize this operation!");
|
||||
return;
|
||||
case ISD::SIGN_EXTEND_INREG:
|
||||
case ISD::ADDC:
|
||||
case ISD::ADDE:
|
||||
case ISD::SUBC:
|
||||
|
@ -825,6 +825,7 @@ namespace llvm {
|
||||
SDValue LowerLOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerMEMBARRIER(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
|
||||
|
||||
// Utility functions to help LowerVECTOR_SHUFFLE
|
||||
SDValue LowerVECTOR_SHUFFLEv8i16(SDValue Op, SelectionDAG &DAG) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user