Skip to content

Commit eeb6394

Browse files
committed
[LegalizeTypes][ARM][AArch64][PowerPC][RISCV][X86] Use BUILD_PAIR to return expanded integer results from ReplaceNodeResults instead of just returning two results.
Remove code from LegalizeTypes that allowed this to work. We were already using BUILD_PAIR for this in some places so this standardizes on a single way to do this.
1 parent 4aa7b9c commit eeb6394

File tree

6 files changed

+21
-31
lines changed

6 files changed

+21
-31
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -912,17 +912,6 @@ bool DAGTypeLegalizer::CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult) {
912912
// The target didn't want to custom lower it after all.
913913
return false;
914914

915-
// When called from DAGTypeLegalizer::ExpandIntegerResult, we might need to
916-
// provide the same kind of custom splitting behavior.
917-
if (Results.size() == N->getNumValues() + 1 && LegalizeResult) {
918-
// We've legalized a return type by splitting it. If there is a chain,
919-
// replace that too.
920-
SetExpandedInteger(SDValue(N, 0), Results[0], Results[1]);
921-
if (N->getNumValues() > 1)
922-
ReplaceValueWith(SDValue(N, 1), Results[2]);
923-
return true;
924-
}
925-
926915
// Make everything that once used N's values now use those in Results instead.
927916
assert(Results.size() == N->getNumValues() &&
928917
"Custom lowering returned the wrong number of results!");

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13041,10 +13041,12 @@ static void ReplaceCMP_SWAP_128Results(SDNode *N,
1304113041
unsigned SubReg1 = AArch64::sube64, SubReg2 = AArch64::subo64;
1304213042
if (DAG.getDataLayout().isBigEndian())
1304313043
std::swap(SubReg1, SubReg2);
13044-
Results.push_back(DAG.getTargetExtractSubreg(SubReg1, SDLoc(N), MVT::i64,
13045-
SDValue(CmpSwap, 0)));
13046-
Results.push_back(DAG.getTargetExtractSubreg(SubReg2, SDLoc(N), MVT::i64,
13047-
SDValue(CmpSwap, 0)));
13044+
SDValue Lo = DAG.getTargetExtractSubreg(SubReg1, SDLoc(N), MVT::i64,
13045+
SDValue(CmpSwap, 0));
13046+
SDValue Hi = DAG.getTargetExtractSubreg(SubReg2, SDLoc(N), MVT::i64,
13047+
SDValue(CmpSwap, 0));
13048+
Results.push_back(
13049+
DAG.getNode(ISD::BUILD_PAIR, SDLoc(N), MVT::i128, Lo, Hi));
1304813050
Results.push_back(SDValue(CmpSwap, 1)); // Chain out
1304913051
return;
1305013052
}
@@ -13060,8 +13062,8 @@ static void ReplaceCMP_SWAP_128Results(SDNode *N,
1306013062
MachineMemOperand *MemOp = cast<MemSDNode>(N)->getMemOperand();
1306113063
DAG.setNodeMemRefs(cast<MachineSDNode>(CmpSwap), {MemOp});
1306213064

13063-
Results.push_back(SDValue(CmpSwap, 0));
13064-
Results.push_back(SDValue(CmpSwap, 1));
13065+
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, SDLoc(N), MVT::i128,
13066+
SDValue(CmpSwap, 0), SDValue(CmpSwap, 1)));
1306513067
Results.push_back(SDValue(CmpSwap, 3));
1306613068
}
1306713069

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9066,8 +9066,7 @@ void ARMTargetLowering::ExpandDIV_Windows(
90669066
DAG.getConstant(32, dl, TLI.getPointerTy(DL)));
90679067
Upper = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, Upper);
90689068

9069-
Results.push_back(Lower);
9070-
Results.push_back(Upper);
9069+
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64, Lower, Upper));
90719070
}
90729071

90739072
static SDValue LowerPredicateLoad(SDValue Op, SelectionDAG &DAG) {
@@ -9230,12 +9229,13 @@ static void ReplaceCMP_SWAP_64Results(SDNode *N,
92309229

92319230
bool isBigEndian = DAG.getDataLayout().isBigEndian();
92329231

9233-
Results.push_back(
9232+
SDValue Lo =
92349233
DAG.getTargetExtractSubreg(isBigEndian ? ARM::gsub_1 : ARM::gsub_0,
9235-
SDLoc(N), MVT::i32, SDValue(CmpSwap, 0)));
9236-
Results.push_back(
9234+
SDLoc(N), MVT::i32, SDValue(CmpSwap, 0));
9235+
SDValue Hi =
92379236
DAG.getTargetExtractSubreg(isBigEndian ? ARM::gsub_0 : ARM::gsub_1,
9238-
SDLoc(N), MVT::i32, SDValue(CmpSwap, 0)));
9237+
SDLoc(N), MVT::i32, SDValue(CmpSwap, 0));
9238+
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, SDLoc(N), MVT::i64, Lo, Hi));
92399239
Results.push_back(SDValue(CmpSwap, 2));
92409240
}
92419241

@@ -9410,8 +9410,8 @@ static void ReplaceLongIntrinsic(SDNode *N, SmallVectorImpl<SDValue> &Results,
94109410
DAG.getVTList(MVT::i32, MVT::i32),
94119411
N->getOperand(1), N->getOperand(2),
94129412
Lo, Hi);
9413-
Results.push_back(LongMul.getValue(0));
9414-
Results.push_back(LongMul.getValue(1));
9413+
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64,
9414+
LongMul.getValue(0), LongMul.getValue(1)));
94159415
}
94169416

94179417
/// ReplaceNodeResults - Replace the results of node with an illegal result

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10496,8 +10496,8 @@ void PPCTargetLowering::ReplaceNodeResults(SDNode *N,
1049610496
SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other);
1049710497
SDValue RTB = DAG.getNode(PPCISD::READ_TIME_BASE, dl, VTs, N->getOperand(0));
1049810498

10499-
Results.push_back(RTB);
10500-
Results.push_back(RTB.getValue(1));
10499+
Results.push_back(
10500+
DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64, RTB, RTB.getValue(1)));
1050110501
Results.push_back(RTB.getValue(2));
1050210502
break;
1050310503
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
884884
SDValue RCW =
885885
DAG.getNode(RISCVISD::READ_CYCLE_WIDE, DL, VTs, N->getOperand(0));
886886

887-
Results.push_back(RCW);
888-
Results.push_back(RCW.getValue(1));
887+
Results.push_back(
888+
DAG.getNode(ISD::BUILD_PAIR, DL, MVT::i64, RCW, RCW.getValue(1)));
889889
Results.push_back(RCW.getValue(2));
890890
break;
891891
}

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28861,8 +28861,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
2886128861
SDValue(Lo.getNode(), 1));
2886228862
Hi = DAG.getNode(ISD::XOR, dl, HalfT, Tmp, Hi);
2886328863
Lo = DAG.getNode(ISD::XOR, dl, HalfT, Tmp, Lo);
28864-
Results.push_back(Lo);
28865-
Results.push_back(Hi);
28864+
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64, Lo, Hi));
2886628865
return;
2886728866
}
2886828867
// We might have generated v2f32 FMIN/FMAX operations. Widen them to v4f32.

0 commit comments

Comments
 (0)