Skip to content

Commit 366ac8c

Browse files
authored
[LegalizeVectorOps] Defer UnrollVectorOp in ExpandFNEG to caller. (#106783)
Make ExpandFNEG return SDValue() when it doesn't expand. The caller already knows how to Unroll when Results is empty.
1 parent 0ba006d commit 366ac8c

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
937937
ExpandUINT_TO_FLOAT(Node, Results);
938938
return;
939939
case ISD::FNEG:
940-
Results.push_back(ExpandFNEG(Node));
941-
return;
940+
if (SDValue Expanded = ExpandFNEG(Node)) {
941+
Results.push_back(Expanded);
942+
return;
943+
}
944+
break;
942945
case ISD::FSUB:
943946
ExpandFSUB(Node, Results);
944947
return;
@@ -1777,16 +1780,16 @@ SDValue VectorLegalizer::ExpandFNEG(SDNode *Node) {
17771780
EVT IntVT = VT.changeVectorElementTypeToInteger();
17781781

17791782
// FIXME: The FSUB check is here to force unrolling v1f64 vectors on AArch64.
1780-
if (TLI.isOperationLegalOrCustom(ISD::XOR, IntVT) &&
1781-
TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) {
1782-
SDLoc DL(Node);
1783-
SDValue Cast = DAG.getNode(ISD::BITCAST, DL, IntVT, Node->getOperand(0));
1784-
SDValue SignMask = DAG.getConstant(
1785-
APInt::getSignMask(IntVT.getScalarSizeInBits()), DL, IntVT);
1786-
SDValue Xor = DAG.getNode(ISD::XOR, DL, IntVT, Cast, SignMask);
1787-
return DAG.getNode(ISD::BITCAST, DL, VT, Xor);
1788-
}
1789-
return DAG.UnrollVectorOp(Node);
1783+
if (!TLI.isOperationLegalOrCustom(ISD::XOR, IntVT) ||
1784+
!TLI.isOperationLegalOrCustom(ISD::FSUB, VT))
1785+
return SDValue();
1786+
1787+
SDLoc DL(Node);
1788+
SDValue Cast = DAG.getNode(ISD::BITCAST, DL, IntVT, Node->getOperand(0));
1789+
SDValue SignMask = DAG.getConstant(
1790+
APInt::getSignMask(IntVT.getScalarSizeInBits()), DL, IntVT);
1791+
SDValue Xor = DAG.getNode(ISD::XOR, DL, IntVT, Cast, SignMask);
1792+
return DAG.getNode(ISD::BITCAST, DL, VT, Xor);
17901793
}
17911794

17921795
void VectorLegalizer::ExpandFSUB(SDNode *Node,

0 commit comments

Comments
 (0)