[llvm] b0832fc - [DAG] Add ISD::isExtVecInRegOpcode helper.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 06:47:40 PDT 2023
Author: Simon Pilgrim
Date: 2023-04-24T14:47:23+01:00
New Revision: b0832fca3f0ef1409045a15728462d297aa5deb4
URL: https://github.com/llvm/llvm-project/commit/b0832fca3f0ef1409045a15728462d297aa5deb4
DIFF: https://github.com/llvm/llvm-project/commit/b0832fca3f0ef1409045a15728462d297aa5deb4.diff
LOG: [DAG] Add ISD::isExtVecInRegOpcode helper.
Match ISD::ANY_EXTEND_VECTOR_INREG\ZERO_EXTEND_VECTOR_INREG\SIGN_EXTEND_VECTOR_INREG opcodes
Added:
Modified:
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 242f35769dbca..9120d97e3cfb4 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -1514,6 +1514,12 @@ inline bool isExtOpcode(unsigned Opcode) {
Opcode == ISD::SIGN_EXTEND;
}
+inline bool isExtVecInRegOpcode(unsigned Opcode) {
+ return Opcode == ISD::ANY_EXTEND_VECTOR_INREG ||
+ Opcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
+ Opcode == ISD::SIGN_EXTEND_VECTOR_INREG;
+}
+
namespace GlobalISel {
/// Return the operation corresponding to !(X op Y), where 'op' is a valid
/// SetCC operation. The U bit of the condition code has
diff erent meanings
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 2b52fb052063d..ade34f70c9768 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12309,11 +12309,7 @@ static SDValue tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
EVT VT = N->getValueType(0);
SDLoc DL(N);
- assert((Opcode == ISD::SIGN_EXTEND || Opcode == ISD::ZERO_EXTEND ||
- Opcode == ISD::ANY_EXTEND ||
- Opcode == ISD::SIGN_EXTEND_VECTOR_INREG ||
- Opcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
- Opcode == ISD::ANY_EXTEND_VECTOR_INREG) &&
+ assert((ISD::isExtOpcode(Opcode) || ISD::isExtVecInRegOpcode(Opcode)) &&
"Expected EXTEND dag node in input!");
// fold (sext c1) -> c1
@@ -14041,9 +14037,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
// fold (sext_in_reg (*_extend_vector_inreg x)) -> (sext_vector_inreg x)
// if x is small enough or if we know that x has more than 1 sign bit and the
// sign_extend_inreg is extending from one of them.
- if (N0.getOpcode() == ISD::ANY_EXTEND_VECTOR_INREG ||
- N0.getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG ||
- N0.getOpcode() == ISD::ZERO_EXTEND_VECTOR_INREG) {
+ if (ISD::isExtVecInRegOpcode(N0.getOpcode())) {
SDValue N00 = N0.getOperand(0);
unsigned N00Bits = N00.getScalarValueSizeInBits();
unsigned DstElts = N0.getValueType().getVectorMinNumElements();
@@ -14211,9 +14205,7 @@ foldExtendVectorInregToExtendOfSubvector(SDNode *N, const TargetLowering &TLI,
Src.getValueType().getVectorElementType(),
VT.getVectorElementCount());
- assert((InregOpcode == ISD::SIGN_EXTEND_VECTOR_INREG ||
- InregOpcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
- InregOpcode == ISD::ANY_EXTEND_VECTOR_INREG) &&
+ assert(ISD::isExtVecInRegOpcode(InregOpcode) &&
"Expected EXTEND_VECTOR_INREG dag node in input!");
// Profitability check: our operand must be an one-use CONCAT_VECTORS.
@@ -24154,9 +24146,7 @@ static SDValue combineTruncationShuffle(ShuffleVectorSDNode *SVN,
SDValue N0 = peekThroughBitcasts(SVN->getOperand(0));
unsigned Opcode = N0.getOpcode();
- if (Opcode != ISD::ANY_EXTEND_VECTOR_INREG &&
- Opcode != ISD::SIGN_EXTEND_VECTOR_INREG &&
- Opcode != ISD::ZERO_EXTEND_VECTOR_INREG)
+ if (!ISD::isExtVecInRegOpcode(Opcode))
return SDValue();
SDValue N00 = N0.getOperand(0);
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index fd319920837ad..7ec6175712a4c 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -56963,12 +56963,7 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
}
}
if (IdxVal == 0 &&
- (InOpcode == ISD::ANY_EXTEND ||
- InOpcode == ISD::ANY_EXTEND_VECTOR_INREG ||
- InOpcode == ISD::ZERO_EXTEND ||
- InOpcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
- InOpcode == ISD::SIGN_EXTEND ||
- InOpcode == ISD::SIGN_EXTEND_VECTOR_INREG) &&
+ (ISD::isExtOpcode(InOpcode) || ISD::isExtVecInRegOpcode(InOpcode)) &&
(SizeInBits == 128 || SizeInBits == 256) &&
InVec.getOperand(0).getValueSizeInBits() >= SizeInBits) {
SDLoc DL(N);
More information about the llvm-commits
mailing list