@@ -577,8 +577,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
577
577
setTargetDAGCombine (ISD::INTRINSIC_W_CHAIN);
578
578
setTargetDAGCombine (ISD::INSERT_VECTOR_ELT);
579
579
580
- setTargetDAGCombine (ISD::GlobalAddress);
581
-
582
580
MaxStoresPerMemset = MaxStoresPerMemsetOptSize = 8 ;
583
581
MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = 4 ;
584
582
MaxStoresPerMemmove = MaxStoresPerMemmoveOptSize = 4 ;
@@ -3679,8 +3677,7 @@ AArch64TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
3679
3677
SDValue AArch64TargetLowering::getTargetNode (GlobalAddressSDNode *N, EVT Ty,
3680
3678
SelectionDAG &DAG,
3681
3679
unsigned Flag) const {
3682
- return DAG.getTargetGlobalAddress (N->getGlobal (), SDLoc (N), Ty,
3683
- N->getOffset (), Flag);
3680
+ return DAG.getTargetGlobalAddress (N->getGlobal (), SDLoc (N), Ty, 0 , Flag);
3684
3681
}
3685
3682
3686
3683
SDValue AArch64TargetLowering::getTargetNode (JumpTableSDNode *N, EVT Ty,
@@ -3755,9 +3752,8 @@ SDValue AArch64TargetLowering::LowerGlobalAddress(SDValue Op,
3755
3752
unsigned char OpFlags =
3756
3753
Subtarget->ClassifyGlobalReference (GV, getTargetMachine ());
3757
3754
3758
- if (OpFlags != AArch64II::MO_NO_FLAG)
3759
- assert (cast<GlobalAddressSDNode>(Op)->getOffset () == 0 &&
3760
- " unexpected offset in global node" );
3755
+ assert (cast<GlobalAddressSDNode>(Op)->getOffset () == 0 &&
3756
+ " unexpected offset in global node" );
3761
3757
3762
3758
// This also catches the large code model case for Darwin.
3763
3759
if ((OpFlags & AArch64II::MO_GOT) != 0 ) {
@@ -4995,8 +4991,10 @@ SDValue AArch64TargetLowering::LowerShiftLeftParts(SDValue Op,
4995
4991
4996
4992
bool AArch64TargetLowering::isOffsetFoldingLegal (
4997
4993
const GlobalAddressSDNode *GA) const {
4998
- // Offsets are folded in the DAG combine rather than here so that we can
4999
- // intelligently choose an offset based on the uses.
4994
+ DEBUG (dbgs () << " Skipping offset folding global address: " );
4995
+ DEBUG (GA->dump ());
4996
+ DEBUG (dbgs () << " AArch64 doesn't support folding offsets into global "
4997
+ " addresses\n " );
5000
4998
return false ;
5001
4999
}
5002
5000
@@ -10619,53 +10617,6 @@ static SDValue performNVCASTCombine(SDNode *N) {
10619
10617
return SDValue ();
10620
10618
}
10621
10619
10622
- // If all users of the globaladdr are of the form (globaladdr + constant), find
10623
- // the smallest constant, fold it into the globaladdr's offset and rewrite the
10624
- // globaladdr as (globaladdr + constant) - constant.
10625
- static SDValue performGlobalAddressCombine (SDNode *N, SelectionDAG &DAG,
10626
- const AArch64Subtarget *Subtarget,
10627
- const TargetMachine &TM) {
10628
- auto *GN = dyn_cast<GlobalAddressSDNode>(N);
10629
- if (!GN || Subtarget->ClassifyGlobalReference (GN->getGlobal (), TM) !=
10630
- AArch64II::MO_NO_FLAG)
10631
- return SDValue ();
10632
-
10633
- uint64_t MinOffset = -1ull ;
10634
- for (SDNode *N : GN->uses ()) {
10635
- if (N->getOpcode () != ISD::ADD)
10636
- return SDValue ();
10637
- auto *C = dyn_cast<ConstantSDNode>(N->getOperand (0 ));
10638
- if (!C)
10639
- C = dyn_cast<ConstantSDNode>(N->getOperand (1 ));
10640
- if (!C)
10641
- return SDValue ();
10642
- MinOffset = std::min (MinOffset, C->getZExtValue ());
10643
- }
10644
- uint64_t Offset = MinOffset + GN->getOffset ();
10645
-
10646
- // Check whether folding this offset is legal. It must not go out of bounds of
10647
- // the referenced object to avoid violating the code model, and must be
10648
- // smaller than 2^21 because this is the largest offset expressible in all
10649
- // object formats.
10650
- //
10651
- // This check also prevents us from folding negative offsets, which will end
10652
- // up being treated in the same way as large positive ones. They could also
10653
- // cause code model violations, and aren't really common enough to matter.
10654
- if (Offset >= (1 << 21 ))
10655
- return SDValue ();
10656
-
10657
- const GlobalValue *GV = GN->getGlobal ();
10658
- Type *T = GV->getValueType ();
10659
- if (!T->isSized () ||
10660
- Offset > GV->getParent ()->getDataLayout ().getTypeAllocSize (T))
10661
- return SDValue ();
10662
-
10663
- SDLoc DL (GN);
10664
- SDValue Result = DAG.getGlobalAddress (GV, DL, MVT::i64 , Offset);
10665
- return DAG.getNode (ISD::SUB, DL, MVT::i64 , Result,
10666
- DAG.getConstant (MinOffset, DL, MVT::i64 ));
10667
- }
10668
-
10669
10620
SDValue AArch64TargetLowering::PerformDAGCombine (SDNode *N,
10670
10621
DAGCombinerInfo &DCI) const {
10671
10622
SelectionDAG &DAG = DCI.DAG ;
@@ -10753,8 +10704,6 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode *N,
10753
10704
default :
10754
10705
break ;
10755
10706
}
10756
- case ISD::GlobalAddress:
10757
- return performGlobalAddressCombine (N, DAG, Subtarget, getTargetMachine ());
10758
10707
}
10759
10708
return SDValue ();
10760
10709
}
0 commit comments