[llvm] 755282e - [SLP][NFC]Move getExtractIndex function for future changes, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 09:54:24 PST 2023
Author: Alexey Bataev
Date: 2023-01-09T09:53:01-08:00
New Revision: 755282ec1e50b9038b31b1e0d6f4fced52cb85e4
URL: https://github.com/llvm/llvm-project/commit/755282ec1e50b9038b31b1e0d6f4fced52cb85e4
DIFF: https://github.com/llvm/llvm-project/commit/755282ec1e50b9038b31b1e0d6f4fced52cb85e4.diff
LOG: [SLP][NFC]Move getExtractIndex function for future changes, NFC.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index dc566dcf83094..49ad18cd61826 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -515,6 +515,24 @@ isFixedVectorShuffle(ArrayRef<Value *> VL, SmallVectorImpl<int> &Mask) {
: TargetTransformInfo::SK_PermuteSingleSrc;
}
+/// \returns True if Extract{Value,Element} instruction extracts element Idx.
+static std::optional<unsigned> getExtractIndex(Instruction *E) {
+ unsigned Opcode = E->getOpcode();
+ assert((Opcode == Instruction::ExtractElement ||
+ Opcode == Instruction::ExtractValue) &&
+ "Expected extractelement or extractvalue instruction.");
+ if (Opcode == Instruction::ExtractElement) {
+ auto *CI = dyn_cast<ConstantInt>(E->getOperand(1));
+ if (!CI)
+ return std::nullopt;
+ return CI->getZExtValue();
+ }
+ auto *EI = cast<ExtractValueInst>(E);
+ if (EI->getNumIndices() != 1)
+ return std::nullopt;
+ return *EI->idx_begin();
+}
+
namespace {
/// Main data required for vectorization of instructions.
@@ -762,24 +780,6 @@ static bool allSameType(ArrayRef<Value *> VL) {
return true;
}
-/// \returns True if Extract{Value,Element} instruction extracts element Idx.
-static std::optional<unsigned> getExtractIndex(Instruction *E) {
- unsigned Opcode = E->getOpcode();
- assert((Opcode == Instruction::ExtractElement ||
- Opcode == Instruction::ExtractValue) &&
- "Expected extractelement or extractvalue instruction.");
- if (Opcode == Instruction::ExtractElement) {
- auto *CI = dyn_cast<ConstantInt>(E->getOperand(1));
- if (!CI)
- return std::nullopt;
- return CI->getZExtValue();
- }
- ExtractValueInst *EI = cast<ExtractValueInst>(E);
- if (EI->getNumIndices() != 1)
- return std::nullopt;
- return *EI->idx_begin();
-}
-
/// \returns True if in-tree use also needs extract. This refers to
/// possible scalar operand in vectorized instruction.
static bool InTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst,
More information about the llvm-commits
mailing list