@@ -2576,8 +2576,7 @@ bool RISCVDAGToDAGISel::SelectAddrFrameIndex(SDValue Addr, SDValue &Base,
25762576static bool selectConstantAddr (SelectionDAG *CurDAG, const SDLoc &DL,
25772577 const MVT VT, const RISCVSubtarget *Subtarget,
25782578 SDValue Addr, SDValue &Base, SDValue &Offset,
2579- bool IsPrefetch = false ,
2580- bool IsRV32Zdinx = false ) {
2579+ bool IsPrefetch = false ) {
25812580 if (!isa<ConstantSDNode>(Addr))
25822581 return false ;
25832582
@@ -2591,9 +2590,6 @@ static bool selectConstantAddr(SelectionDAG *CurDAG, const SDLoc &DL,
25912590 if (!Subtarget->is64Bit () || isInt<32 >(Hi)) {
25922591 if (IsPrefetch && (Lo12 & 0b11111 ) != 0 )
25932592 return false ;
2594- if (IsRV32Zdinx && !isInt<12 >(Lo12 + 4 ))
2595- return false ;
2596-
25972593 if (Hi) {
25982594 int64_t Hi20 = (Hi >> 12 ) & 0xfffff ;
25992595 Base = SDValue (
@@ -2617,8 +2613,6 @@ static bool selectConstantAddr(SelectionDAG *CurDAG, const SDLoc &DL,
26172613 Lo12 = Seq.back ().getImm ();
26182614 if (IsPrefetch && (Lo12 & 0b11111 ) != 0 )
26192615 return false ;
2620- if (IsRV32Zdinx && !isInt<12 >(Lo12 + 4 ))
2621- return false ;
26222616
26232617 // Drop the last instruction.
26242618 Seq.pop_back ();
@@ -2710,47 +2704,22 @@ bool RISCVDAGToDAGISel::SelectAddrRegRegScale(SDValue Addr,
27102704}
27112705
27122706bool RISCVDAGToDAGISel::SelectAddrRegImm (SDValue Addr, SDValue &Base,
2713- SDValue &Offset, bool IsRV32Zdinx ) {
2707+ SDValue &Offset) {
27142708 if (SelectAddrFrameIndex (Addr, Base, Offset))
27152709 return true ;
27162710
27172711 SDLoc DL (Addr);
27182712 MVT VT = Addr.getSimpleValueType ();
27192713
27202714 if (Addr.getOpcode () == RISCVISD::ADD_LO) {
2721- // If this is non RV32Zdinx we can always fold.
2722- if (!IsRV32Zdinx) {
2723- Base = Addr.getOperand (0 );
2724- Offset = Addr.getOperand (1 );
2725- return true ;
2726- }
2727-
2728- // For RV32Zdinx we need to have more than 4 byte alignment so we can add 4
2729- // to the offset when we expand in RISCVExpandPseudoInsts.
2730- if (auto *GA = dyn_cast<GlobalAddressSDNode>(Addr.getOperand (1 ))) {
2731- const DataLayout &DL = CurDAG->getDataLayout ();
2732- Align Alignment = commonAlignment (
2733- GA->getGlobal ()->getPointerAlignment (DL), GA->getOffset ());
2734- if (Alignment > 4 ) {
2735- Base = Addr.getOperand (0 );
2736- Offset = Addr.getOperand (1 );
2737- return true ;
2738- }
2739- }
2740- if (auto *CP = dyn_cast<ConstantPoolSDNode>(Addr.getOperand (1 ))) {
2741- Align Alignment = commonAlignment (CP->getAlign (), CP->getOffset ());
2742- if (Alignment > 4 ) {
2743- Base = Addr.getOperand (0 );
2744- Offset = Addr.getOperand (1 );
2745- return true ;
2746- }
2747- }
2715+ Base = Addr.getOperand (0 );
2716+ Offset = Addr.getOperand (1 );
2717+ return true ;
27482718 }
27492719
2750- int64_t RV32ZdinxRange = IsRV32Zdinx ? 4 : 0 ;
27512720 if (CurDAG->isBaseWithConstantOffset (Addr)) {
27522721 int64_t CVal = cast<ConstantSDNode>(Addr.getOperand (1 ))->getSExtValue ();
2753- if (isInt<12 >(CVal) && isInt<12 >(CVal + RV32ZdinxRange )) {
2722+ if (isInt<12 >(CVal) && isInt<12 >(CVal)) {
27542723 Base = Addr.getOperand (0 );
27552724 if (Base.getOpcode () == RISCVISD::ADD_LO) {
27562725 SDValue LoOperand = Base.getOperand (1 );
@@ -2763,8 +2732,7 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
27632732 const DataLayout &DL = CurDAG->getDataLayout ();
27642733 Align Alignment = commonAlignment (
27652734 GA->getGlobal ()->getPointerAlignment (DL), GA->getOffset ());
2766- if ((CVal == 0 || Alignment > CVal) &&
2767- (!IsRV32Zdinx || commonAlignment (Alignment, CVal) > 4 )) {
2735+ if ((CVal == 0 || Alignment > CVal)) {
27682736 int64_t CombinedOffset = CVal + GA->getOffset ();
27692737 Base = Base.getOperand (0 );
27702738 Offset = CurDAG->getTargetGlobalAddress (
@@ -2785,13 +2753,13 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
27852753 // Handle ADD with large immediates.
27862754 if (Addr.getOpcode () == ISD::ADD && isa<ConstantSDNode>(Addr.getOperand (1 ))) {
27872755 int64_t CVal = cast<ConstantSDNode>(Addr.getOperand (1 ))->getSExtValue ();
2788- assert (!(isInt<12 >(CVal) && isInt<12 >(CVal + RV32ZdinxRange )) &&
2756+ assert (!(isInt<12 >(CVal) && isInt<12 >(CVal)) &&
27892757 " simm12 not already handled?" );
27902758
27912759 // Handle immediates in the range [-4096,-2049] or [2048, 4094]. We can use
27922760 // an ADDI for part of the offset and fold the rest into the load/store.
27932761 // This mirrors the AddiPair PatFrag in RISCVInstrInfo.td.
2794- if (CVal >= -4096 && CVal <= ( 4094 - RV32ZdinxRange) ) {
2762+ if (CVal >= -4096 && CVal <= 4094 ) {
27952763 int64_t Adj = CVal < 0 ? -2048 : 2047 ;
27962764 Base = SDValue (
27972765 CurDAG->getMachineNode (RISCV::ADDI, DL, VT, Addr.getOperand (0 ),
@@ -2809,7 +2777,7 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
28092777 // instructions.
28102778 if (isWorthFoldingAdd (Addr) &&
28112779 selectConstantAddr (CurDAG, DL, VT, Subtarget, Addr.getOperand (1 ), Base,
2812- Offset, /* IsPrefetch=*/ false , RV32ZdinxRange )) {
2780+ Offset, /* IsPrefetch=*/ false )) {
28132781 // Insert an ADD instruction with the materialized Hi52 bits.
28142782 Base = SDValue (
28152783 CurDAG->getMachineNode (RISCV::ADD, DL, VT, Addr.getOperand (0 ), Base),
@@ -2819,7 +2787,7 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
28192787 }
28202788
28212789 if (selectConstantAddr (CurDAG, DL, VT, Subtarget, Addr, Base, Offset,
2822- /* IsPrefetch=*/ false , RV32ZdinxRange ))
2790+ /* IsPrefetch=*/ false ))
28232791 return true ;
28242792
28252793 Base = Addr;
0 commit comments