@@ -3569,18 +3569,50 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
3569
3569
}
3570
3570
break ;
3571
3571
3572
- case ISD::FP_EXTEND:
3572
+ case ISD::FP_EXTEND: {
3573
+ MVT::ValueType newVT = Op.getValueType ();
3574
+ MVT::ValueType oldVT = Op.getOperand (0 ).getValueType ();
3575
+ if (TLI.getConvertAction (oldVT, newVT) == TargetLowering::Expand) {
3576
+ // The only other way we can lower this is to turn it into a STORE,
3577
+ // LOAD pair, targetting a temporary ___location (a stack slot).
3578
+
3579
+ // NOTE: there is a choice here between constantly creating new stack
3580
+ // slots and always reusing the same one. We currently always create
3581
+ // new ones, as reuse may inhibit scheduling.
3582
+ const Type *Ty = MVT::getTypeForValueType (oldVT);
3583
+ uint64_t TySize = TLI.getTargetData ()->getABITypeSize (Ty);
3584
+ unsigned Align = TLI.getTargetData ()->getPrefTypeAlignment (Ty);
3585
+ MachineFunction &MF = DAG.getMachineFunction ();
3586
+ int SSFI =
3587
+ MF.getFrameInfo ()->CreateStackObject (TySize, Align);
3588
+ SDOperand StackSlot = DAG.getFrameIndex (SSFI, TLI.getPointerTy ());
3589
+ Result = DAG.getStore (DAG.getEntryNode (), Node->getOperand (0 ),
3590
+ StackSlot, NULL , 0 );
3591
+ Result = DAG.getExtLoad (ISD::EXTLOAD, newVT,
3592
+ Result, StackSlot, NULL , 0 , oldVT);
3593
+ break ;
3594
+ }
3595
+ }
3596
+ switch (getTypeAction (Node->getOperand (0 ).getValueType ())) {
3597
+ case Expand: assert (0 && " Shouldn't need to expand other operators here!" );
3598
+ case Legal:
3599
+ Tmp1 = LegalizeOp (Node->getOperand (0 ));
3600
+ Result = DAG.UpdateNodeOperands (Result, Tmp1);
3601
+ break ;
3602
+ case Promote:
3603
+ Tmp1 = PromoteOp (Node->getOperand (0 ));
3604
+ Result = DAG.getNode (ISD::FP_EXTEND, Op.getValueType (), Tmp1);
3605
+ break ;
3606
+ }
3607
+ break ;
3573
3608
case ISD::FP_ROUND: {
3574
3609
MVT::ValueType newVT = Op.getValueType ();
3575
3610
MVT::ValueType oldVT = Op.getOperand (0 ).getValueType ();
3576
3611
if (TLI.getConvertAction (oldVT, newVT) == TargetLowering::Expand) {
3577
- if (Node-> getOpcode () == ISD::FP_ROUND && oldVT == MVT::ppcf128) {
3612
+ if (oldVT == MVT::ppcf128) {
3578
3613
SDOperand Lo, Hi;
3579
3614
ExpandOp (Node->getOperand (0 ), Lo, Hi);
3580
- if (newVT == MVT::f64 )
3581
- Result = Hi;
3582
- else
3583
- Result = DAG.getNode (ISD::FP_ROUND, newVT, Hi);
3615
+ Result = DAG.getNode (ISD::FP_ROUND, newVT, Hi);
3584
3616
break ;
3585
3617
} else {
3586
3618
// The only other way we can lower this is to turn it into a STORE,
@@ -3589,30 +3621,31 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
3589
3621
// NOTE: there is a choice here between constantly creating new stack
3590
3622
// slots and always reusing the same one. We currently always create
3591
3623
// new ones, as reuse may inhibit scheduling.
3592
- MVT::ValueType slotVT =
3593
- (Node->getOpcode () == ISD::FP_EXTEND) ? oldVT : newVT;
3594
- const Type *Ty = MVT::getTypeForValueType (slotVT);
3624
+ const Type *Ty = MVT::getTypeForValueType (newVT);
3595
3625
uint64_t TySize = TLI.getTargetData ()->getABITypeSize (Ty);
3596
3626
unsigned Align = TLI.getTargetData ()->getPrefTypeAlignment (Ty);
3597
3627
MachineFunction &MF = DAG.getMachineFunction ();
3598
- int SSFI =
3599
- MF.getFrameInfo ()->CreateStackObject (TySize, Align);
3628
+ int SSFI = MF.getFrameInfo ()->CreateStackObject (TySize, Align);
3600
3629
SDOperand StackSlot = DAG.getFrameIndex (SSFI, TLI.getPointerTy ());
3601
- if (Node->getOpcode () == ISD::FP_EXTEND) {
3602
- Result = DAG.getStore (DAG.getEntryNode (), Node->getOperand (0 ),
3603
- StackSlot, NULL , 0 );
3604
- Result = DAG.getExtLoad (ISD::EXTLOAD, newVT,
3605
- Result, StackSlot, NULL , 0 , oldVT);
3606
- } else {
3607
- Result = DAG.getTruncStore (DAG.getEntryNode (), Node->getOperand (0 ),
3608
- StackSlot, NULL , 0 , newVT);
3609
- Result = DAG.getLoad (newVT, Result, StackSlot, NULL , 0 );
3610
- }
3630
+ Result = DAG.getTruncStore (DAG.getEntryNode (), Node->getOperand (0 ),
3631
+ StackSlot, NULL , 0 , newVT);
3632
+ Result = DAG.getLoad (newVT, Result, StackSlot, NULL , 0 );
3611
3633
break ;
3612
3634
}
3613
3635
}
3614
3636
}
3615
- // FALL THROUGH
3637
+ switch (getTypeAction (Node->getOperand (0 ).getValueType ())) {
3638
+ case Expand: assert (0 && " Shouldn't need to expand other operators here!" );
3639
+ case Legal:
3640
+ Tmp1 = LegalizeOp (Node->getOperand (0 ));
3641
+ Result = DAG.UpdateNodeOperands (Result, Tmp1);
3642
+ break ;
3643
+ case Promote:
3644
+ Tmp1 = PromoteOp (Node->getOperand (0 ));
3645
+ Result = DAG.getNode (ISD::FP_ROUND, Op.getValueType (), Tmp1);
3646
+ break ;
3647
+ }
3648
+ break ;
3616
3649
case ISD::ANY_EXTEND:
3617
3650
case ISD::ZERO_EXTEND:
3618
3651
case ISD::SIGN_EXTEND:
@@ -3641,16 +3674,6 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
3641
3674
Result,
3642
3675
DAG.getValueType (Node->getOperand (0 ).getValueType ()));
3643
3676
break ;
3644
- case ISD::FP_EXTEND:
3645
- Result = PromoteOp (Node->getOperand (0 ));
3646
- if (Result.getValueType () != Op.getValueType ())
3647
- // Dynamically dead while we have only 2 FP types.
3648
- Result = DAG.getNode (ISD::FP_EXTEND, Op.getValueType (), Result);
3649
- break ;
3650
- case ISD::FP_ROUND:
3651
- Result = PromoteOp (Node->getOperand (0 ));
3652
- Result = DAG.getNode (Node->getOpcode (), Op.getValueType (), Result);
3653
- break ;
3654
3677
}
3655
3678
}
3656
3679
break ;
0 commit comments