Skip to content

[LegalizeVectorOps] Defer UnrollVectorOp in ExpandFNEG to caller. #106783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
ExpandUINT_TO_FLOAT(Node, Results);
return;
case ISD::FNEG:
Results.push_back(ExpandFNEG(Node));
return;
if (SDValue Expanded = ExpandFNEG(Node)) {
Results.push_back(Expanded);
return;
}
break;
case ISD::FSUB:
ExpandFSUB(Node, Results);
return;
Expand Down Expand Up @@ -1773,16 +1776,16 @@ SDValue VectorLegalizer::ExpandFNEG(SDNode *Node) {
EVT IntVT = VT.changeVectorElementTypeToInteger();

// FIXME: The FSUB check is here to force unrolling v1f64 vectors on AArch64.
if (TLI.isOperationLegalOrCustom(ISD::XOR, IntVT) &&
TLI.isOperationLegalOrCustom(ISD::FSUB, VT)) {
SDLoc DL(Node);
SDValue Cast = DAG.getNode(ISD::BITCAST, DL, IntVT, Node->getOperand(0));
SDValue SignMask = DAG.getConstant(
APInt::getSignMask(IntVT.getScalarSizeInBits()), DL, IntVT);
SDValue Xor = DAG.getNode(ISD::XOR, DL, IntVT, Cast, SignMask);
return DAG.getNode(ISD::BITCAST, DL, VT, Xor);
}
return DAG.UnrollVectorOp(Node);
if (!TLI.isOperationLegalOrCustom(ISD::XOR, IntVT) ||
!TLI.isOperationLegalOrCustom(ISD::FSUB, VT))
return SDValue();

SDLoc DL(Node);
SDValue Cast = DAG.getNode(ISD::BITCAST, DL, IntVT, Node->getOperand(0));
SDValue SignMask = DAG.getConstant(
APInt::getSignMask(IntVT.getScalarSizeInBits()), DL, IntVT);
SDValue Xor = DAG.getNode(ISD::XOR, DL, IntVT, Cast, SignMask);
return DAG.getNode(ISD::BITCAST, DL, VT, Xor);
}

void VectorLegalizer::ExpandFSUB(SDNode *Node,
Expand Down
Loading