Skip to content

Commit 87c9657

Browse files
committed
Style fixups
1 parent 92037f8 commit 87c9657

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,15 +801,15 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS(SDNode *N) {
801801

802802
auto [ReturnVal, Chain] = TLI.makeLibCall(DAG, LC, NVT, Ops, CallOptions, DL,
803803
/*Chain=*/SDValue());
804-
unsigned ResNo = 0;
805-
for (SDValue OutPtr : {StackSlotSin, StackSlotCos}) {
806-
int FrameIdx = cast<FrameIndexSDNode>(OutPtr)->getIndex();
804+
805+
auto CreateStackLoad = [&, Chain = Chain](SDValue StackSlot) {
806+
int FrameIdx = cast<FrameIndexSDNode>(StackSlot)->getIndex();
807807
auto PtrInfo =
808808
MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FrameIdx);
809-
810-
SDValue LoadExp = DAG.getLoad(NVT, DL, Chain, OutPtr, PtrInfo);
811-
SetSoftenedFloat(SDValue(N, ResNo++), LoadExp);
812-
}
809+
return DAG.getLoad(NVT, DL, Chain, StackSlot, PtrInfo);
810+
};
811+
SetSoftenedFloat(SDValue(N, 0), CreateStackLoad(StackSlotSin));
812+
SetSoftenedFloat(SDValue(N, 1), CreateStackLoad(StackSlotCos));
813813

814814
return SDValue();
815815
}
@@ -2949,8 +2949,10 @@ SDValue DAGTypeLegalizer::PromoteFloatRes_FSINCOS(SDNode *N) {
29492949
SDValue Op = GetPromotedFloat(N->getOperand(0));
29502950
SDValue Res = DAG.getNode(N->getOpcode(), SDLoc(N), {NVT, NVT}, Op);
29512951

2952-
for (unsigned ResNum = 0; ResNum < N->getNumValues(); ResNum++)
2952+
for (unsigned ResNum = 0, NumValues = N->getNumValues(); ResNum < NumValues;
2953+
++ResNum) {
29532954
SetPromotedFloat(SDValue(N, ResNum), Res.getValue(ResNum));
2955+
}
29542956

29552957
return SDValue();
29562958
}
@@ -3376,7 +3378,8 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FSINCOS(SDNode *N) {
33763378

33773379
// Convert back to FP16 as an integer.
33783380
ISD::NodeType Truncate = GetPromotionOpcode(NVT, OVT);
3379-
for (unsigned ResNum = 0; ResNum < N->getNumValues(); ResNum++) {
3381+
for (unsigned ResNum = 0, NumValues = N->getNumValues(); ResNum < NumValues;
3382+
++ResNum) {
33803383
SDValue Trunc = DAG.getNode(Truncate, dl, MVT::i16, Res.getValue(ResNum));
33813384
SetSoftPromotedHalf(SDValue(N, ResNum), Trunc);
33823385
}

0 commit comments

Comments
 (0)