[llvm] cfe2b81 - [SVE] Update INSERT_SUBVECTOR DAGCombine to use getVectorElementCount().
Cameron McInally via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 14:51:54 PDT 2020
Author: Cameron McInally
Date: 2020-09-01T16:51:44-05:00
New Revision: cfe2b81710c43e5c227b16c006e40ced82e1d829
URL: https://github.com/llvm/llvm-project/commit/cfe2b81710c43e5c227b16c006e40ced82e1d829
DIFF: https://github.com/llvm/llvm-project/commit/cfe2b81710c43e5c227b16c006e40ced82e1d829.diff
LOG: [SVE] Update INSERT_SUBVECTOR DAGCombine to use getVectorElementCount().
A small piece of the project to replace getVectorNumElements() with getVectorElementCount().
Differential Revision: https://reviews.llvm.org/D86894
Added:
Modified:
llvm/include/llvm/Support/TypeSize.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index 6573501b6199..b6392e61db4b 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Support/TypeSize.h
@@ -79,6 +79,10 @@ class ElementCount {
return {(unsigned)llvm::NextPowerOf2(Min), Scalable};
}
+ bool isKnownMultipleOf(unsigned RHS) const {
+ return Min % RHS == 0;
+ }
+
static ElementCount getFixed(unsigned Min) { return {Min, false}; }
static ElementCount getScalable(unsigned Min) { return {Min, true}; }
static ElementCount get(unsigned Min, bool Scalable) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8c1e88066f95..60fba1cc4e20 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20620,7 +20620,7 @@ SDValue DAGCombiner::visitINSERT_SUBVECTOR(SDNode *N) {
SDLoc DL(N);
SDValue NewIdx;
LLVMContext &Ctx = *DAG.getContext();
- unsigned NumElts = VT.getVectorNumElements();
+ ElementCount NumElts = VT.getVectorElementCount();
unsigned EltSizeInBits = VT.getScalarSizeInBits();
if ((EltSizeInBits % N1SrcSVT.getSizeInBits()) == 0) {
unsigned Scale = EltSizeInBits / N1SrcSVT.getSizeInBits();
@@ -20628,7 +20628,7 @@ SDValue DAGCombiner::visitINSERT_SUBVECTOR(SDNode *N) {
NewIdx = DAG.getVectorIdxConstant(InsIdx * Scale, DL);
} else if ((N1SrcSVT.getSizeInBits() % EltSizeInBits) == 0) {
unsigned Scale = N1SrcSVT.getSizeInBits() / EltSizeInBits;
- if ((NumElts % Scale) == 0 && (InsIdx % Scale) == 0) {
+ if (NumElts.isKnownMultipleOf(Scale) && (InsIdx % Scale) == 0) {
NewVT = EVT::getVectorVT(Ctx, N1SrcSVT, NumElts / Scale);
NewIdx = DAG.getVectorIdxConstant(InsIdx / Scale, DL);
}
More information about the llvm-commits
mailing list