[llvm] 3146d57 - [X86][NFC] Hoist out `N->getOpcode()` used in ReplaceNodeResults (#119494)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 20:54:26 PST 2024
Author: Phoebe Wang
Date: 2024-12-11T12:54:23+08:00
New Revision: 3146d57b646c869564669c3e074d6d4fc1ca7500
URL: https://github.com/llvm/llvm-project/commit/3146d57b646c869564669c3e074d6d4fc1ca7500
DIFF: https://github.com/llvm/llvm-project/commit/3146d57b646c869564669c3e074d6d4fc1ca7500.diff
LOG: [X86][NFC] Hoist out `N->getOpcode()` used in ReplaceNodeResults (#119494)
Address comment from
https://github.com/llvm/llvm-project/pull/119391/files#r1878388699
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 871de16d66b6c5..decd9a64d8845b 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -33262,7 +33262,8 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
SmallVectorImpl<SDValue>&Results,
SelectionDAG &DAG) const {
SDLoc dl(N);
- switch (N->getOpcode()) {
+ unsigned Opc = N->getOpcode();
+ switch (Opc) {
default:
#ifndef NDEBUG
dbgs() << "ReplaceNodeResults: ";
@@ -33358,7 +33359,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
EVT VT = N->getValueType(0);
assert(getTypeAction(*DAG.getContext(), VT) == TypeWidenVector &&
VT == MVT::v2i32 && "Unexpected VT!");
- bool IsSigned = N->getOpcode() == ISD::SMULO;
+ bool IsSigned = Opc == ISD::SMULO;
unsigned ExtOpc = IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
SDValue Op0 = DAG.getNode(ExtOpc, dl, MVT::v2i64, N->getOperand(0));
SDValue Op1 = DAG.getNode(ExtOpc, dl, MVT::v2i64, N->getOperand(1));
@@ -33415,7 +33416,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
Ops[0] = N->getOperand(1);
SDValue InVec1 = DAG.getNode(ISD::CONCAT_VECTORS, dl, InWideVT, Ops);
- SDValue Res = DAG.getNode(N->getOpcode(), dl, WideVT, InVec0, InVec1);
+ SDValue Res = DAG.getNode(Opc, dl, WideVT, InVec0, InVec1);
Results.push_back(Res);
return;
}
@@ -33453,7 +33454,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
EVT ResVT = getTypeToTransformTo(*DAG.getContext(), VT);
SDValue N0 = DAG.getNode(ISD::CONCAT_VECTORS, dl, ResVT, Ops0);
SDValue N1 = DAG.getConstant(SplatVal, dl, ResVT);
- SDValue Res = DAG.getNode(N->getOpcode(), dl, ResVT, N0, N1);
+ SDValue Res = DAG.getNode(Opc, dl, ResVT, N0, N1);
Results.push_back(Res);
}
return;
@@ -33574,7 +33575,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
(InVT == MVT::v4i16 || InVT == MVT::v4i8)){
assert(getTypeAction(*DAG.getContext(), InVT) == TypeWidenVector &&
"Unexpected type action!");
- assert(N->getOpcode() == ISD::SIGN_EXTEND && "Unexpected opcode");
+ assert(Opc == ISD::SIGN_EXTEND && "Unexpected opcode");
// Custom split this so we can extend i8/i16->i32 invec. This is better
// since sign_extend_inreg i8/i16->i64 requires an extend to i32 using
// sra. Then extending from i32 to i64 using pcmpgt. By custom splitting
@@ -33611,7 +33612,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
// Promote the input to 128 bits. Type legalization will turn this into
// zext_inreg/sext_inreg.
- In = DAG.getNode(N->getOpcode(), dl, InVT, In);
+ In = DAG.getNode(Opc, dl, InVT, In);
}
// Perform custom splitting instead of the two stage extend we would get
@@ -33620,7 +33621,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
assert(isTypeLegal(LoVT) && "Split VT not legal?");
- SDValue Lo = getEXTEND_VECTOR_INREG(N->getOpcode(), dl, LoVT, In, DAG);
+ SDValue Lo = getEXTEND_VECTOR_INREG(Opc, dl, LoVT, In, DAG);
// We need to shift the input over by half the number of elements.
unsigned NumElts = InVT.getVectorNumElements();
@@ -33630,7 +33631,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
ShufMask[i] = i + HalfNumElts;
SDValue Hi = DAG.getVectorShuffle(InVT, dl, In, In, ShufMask);
- Hi = getEXTEND_VECTOR_INREG(N->getOpcode(), dl, HiVT, Hi, DAG);
+ Hi = getEXTEND_VECTOR_INREG(Opc, dl, HiVT, Hi, DAG);
SDValue Res = DAG.getNode(ISD::CONCAT_VECTORS, dl, VT, Lo, Hi);
Results.push_back(Res);
@@ -33642,8 +33643,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
case ISD::FP_TO_UINT:
case ISD::STRICT_FP_TO_UINT: {
bool IsStrict = N->isStrictFPOpcode();
- bool IsSigned = N->getOpcode() == ISD::FP_TO_SINT ||
- N->getOpcode() == ISD::STRICT_FP_TO_SINT;
+ bool IsSigned = Opc == ISD::FP_TO_SINT || Opc == ISD::STRICT_FP_TO_SINT;
EVT VT = N->getValueType(0);
SDValue Src = N->getOperand(IsStrict ? 1 : 0);
SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
@@ -33654,13 +33654,13 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
EVT NVT = VT.isVector() ? VT.changeVectorElementType(MVT::f32) : MVT::f32;
if (IsStrict) {
Res =
- DAG.getNode(N->getOpcode(), dl, {VT, MVT::Other},
+ DAG.getNode(Opc, dl, {VT, MVT::Other},
{Chain, DAG.getNode(ISD::STRICT_FP_EXTEND, dl,
{NVT, MVT::Other}, {Chain, Src})});
Chain = Res.getValue(1);
} else {
- Res = DAG.getNode(N->getOpcode(), dl, VT,
- DAG.getNode(ISD::FP_EXTEND, dl, NVT, Src));
+ Res =
+ DAG.getNode(Opc, dl, VT, DAG.getNode(ISD::FP_EXTEND, dl, NVT, Src));
}
Results.push_back(Res);
if (IsStrict)
@@ -33683,13 +33683,12 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
}
if (IsStrict) {
- unsigned Opc =
- IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI;
+ Opc = IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI;
Res =
DAG.getNode(Opc, dl, {ResVT, MVT::Other}, {N->getOperand(0), Src});
Chain = Res.getValue(1);
} else {
- unsigned Opc = IsSigned ? X86ISD::CVTTP2SI : X86ISD::CVTTP2UI;
+ Opc = IsSigned ? X86ISD::CVTTP2SI : X86ISD::CVTTP2UI;
Res = DAG.getNode(Opc, dl, ResVT, Src);
}
@@ -33775,7 +33774,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
return;
}
- unsigned Opc;
if (IsStrict)
Opc = IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI;
else
@@ -33814,7 +33812,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
if (Src.getValueType() == MVT::v2f32 && IsStrict) {
Src = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v4f32, Src,
DAG.getConstantFP(0.0, dl, MVT::v2f32));
- SDValue Res = DAG.getNode(N->getOpcode(), dl, {MVT::v4i32, MVT::Other},
+ SDValue Res = DAG.getNode(Opc, dl, {MVT::v4i32, MVT::Other},
{N->getOperand(0), Src});
Results.push_back(Res);
Results.push_back(Res.getValue(1));
@@ -33838,7 +33836,6 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
std::max(NumElts, 128U / (unsigned)SrcVT.getSizeInBits());
MVT VecVT = MVT::getVectorVT(MVT::i64, NumElts);
MVT VecInVT = MVT::getVectorVT(SrcVT.getSimpleVT(), SrcElts);
- unsigned Opc = N->getOpcode();
if (NumElts != SrcElts) {
if (IsStrict)
Opc = IsSigned ? X86ISD::STRICT_CVTTP2SI : X86ISD::STRICT_CVTTP2UI;
@@ -33892,8 +33889,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
case ISD::UINT_TO_FP:
case ISD::STRICT_UINT_TO_FP: {
bool IsStrict = N->isStrictFPOpcode();
- bool IsSigned = N->getOpcode() == ISD::SINT_TO_FP ||
- N->getOpcode() == ISD::STRICT_SINT_TO_FP;
+ bool IsSigned = Opc == ISD::SINT_TO_FP || Opc == ISD::STRICT_SINT_TO_FP;
EVT VT = N->getValueType(0);
SDValue Src = N->getOperand(IsStrict ? 1 : 0);
if (VT.getVectorElementType() == MVT::f16 && Subtarget.hasFP16() &&
@@ -33987,7 +33983,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
// FIXME: Should generic type legalizer do this?
Src = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v4i32, Src,
DAG.getConstant(0, dl, MVT::v2i32));
- SDValue Res = DAG.getNode(N->getOpcode(), dl, {MVT::v4f32, MVT::Other},
+ SDValue Res = DAG.getNode(Opc, dl, {MVT::v4f32, MVT::Other},
{N->getOperand(0), Src});
Results.push_back(Res);
Results.push_back(Res.getValue(1));
More information about the llvm-commits
mailing list