-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SandboxVec][BottomUpVec] Implement InstrMaps #122848
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
Conversation
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: vporpo (vporpo) ChangesInstrMaps is a helper data structure that maps scalars to vectors and the reverse. This is used by the vectorizer to figure out which vectors it can extract scalar values from. Patch is 30.57 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122848.diff 11 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h
new file mode 100644
index 00000000000000..35d27315541217
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h
@@ -0,0 +1,77 @@
+//===- InstructionMaps.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
+#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/SandboxIR/Value.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm::sandboxir {
+
+/// Maps the original instructions to the vectorized instrs and the reverse.
+/// For now an original instr can only map to a single vector.
+class InstrMaps {
+ /// A map from the original values that got combined into vectors, to the
+ /// vector value(s).
+ DenseMap<Value *, Value *> OrigToVectorMap;
+ /// A map from the vector value to a map of the original value to its lane.
+ /// Please note that for constant vectors, there may multiple original values
+ /// with the same lane, as they may be coming from vectorizing different
+ /// original values.
+ DenseMap<Value *, DenseMap<Value *, unsigned>> VectorToOrigLaneMap;
+
+public:
+ /// \Returns all the vector value that we got from vectorizing \p Orig, or
+ /// nullptr if not found.
+ Value *getVectorForOrig(Value *Orig) const {
+ auto It = OrigToVectorMap.find(Orig);
+ return It != OrigToVectorMap.end() ? It->second : nullptr;
+ }
+ /// \Returns the lane of \p Orig before it got vectorized into \p Vec, or
+ /// nullopt if not found.
+ std::optional<int> getOrigLane(Value *Vec, Value *Orig) const {
+ auto It1 = VectorToOrigLaneMap.find(Vec);
+ if (It1 == VectorToOrigLaneMap.end())
+ return std::nullopt;
+ const auto &OrigToLaneMap = It1->second;
+ auto It2 = OrigToLaneMap.find(Orig);
+ if (It2 == OrigToLaneMap.end())
+ return std::nullopt;
+ return It2->second;
+ }
+ /// Update the map to reflect that \p Origs got vectorized into \p Vec.
+ void registerVector(ArrayRef<Value *> Origs, Value *Vec) {
+ auto &OrigToLaneMap = VectorToOrigLaneMap[Vec];
+ for (auto [Lane, Orig] : enumerate(Origs)) {
+ auto Pair = OrigToVectorMap.try_emplace(Orig, Vec);
+ assert(Pair.second && "Orig already exists in the map!");
+ OrigToLaneMap[Orig] = Lane;
+ }
+ }
+ void clear() {
+ OrigToVectorMap.clear();
+ VectorToOrigLaneMap.clear();
+ }
+#ifndef NDEBUG
+ void dump(raw_ostream &OS) const {
+ OS << "OrigToVectorMap:\n";
+ for (auto [Orig, Vec] : OrigToVectorMap)
+ OS << *Orig << " : " << *Vec << "\n";
+ }
+ LLVM_DUMP_METHOD void dump() const;
+#endif
+};
+} // namespace llvm::sandboxir
+
+#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
index 233cf82a1b3dfb..fe5b269f09e589 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
@@ -23,10 +23,12 @@ namespace llvm::sandboxir {
class LegalityAnalysis;
class Value;
+class InstrMaps;
enum class LegalityResultID {
- Pack, ///> Collect scalar values.
- Widen, ///> Vectorize by combining scalars to a vector.
+ Pack, ///> Collect scalar values.
+ Widen, ///> Vectorize by combining scalars to a vector.
+ DiamondReuse, ///> Don't generate new code, reuse existing vector.
};
/// The reason for vectorizing or not vectorizing.
@@ -50,6 +52,8 @@ struct ToStr {
return "Pack";
case LegalityResultID::Widen:
return "Widen";
+ case LegalityResultID::DiamondReuse:
+ return "DiamondReuse";
}
llvm_unreachable("Unknown LegalityResultID enum");
}
@@ -137,6 +141,19 @@ class Widen final : public LegalityResult {
}
};
+class DiamondReuse final : public LegalityResult {
+ friend class LegalityAnalysis;
+ Value *Vec;
+ DiamondReuse(Value *Vec)
+ : LegalityResult(LegalityResultID::DiamondReuse), Vec(Vec) {}
+
+public:
+ static bool classof(const LegalityResult *From) {
+ return From->getSubclassID() == LegalityResultID::DiamondReuse;
+ }
+ Value *getVector() const { return Vec; }
+};
+
class Pack final : public LegalityResultWithReason {
Pack(ResultReason Reason)
: LegalityResultWithReason(LegalityResultID::Pack, Reason) {}
@@ -148,6 +165,57 @@ class Pack final : public LegalityResultWithReason {
}
};
+/// Describes how to collect the values needed by each lane.
+class CollectDescr {
+public:
+ /// Describes how to get a value element. If the value is a vector then it
+ /// also provides the index to extract it from.
+ class ExtractElementDescr {
+ Value *V;
+ /// The index in `V` that the value can be extracted from.
+ /// This is nullopt if we need to use `V` as a whole.
+ std::optional<int> ExtractIdx;
+
+ public:
+ ExtractElementDescr(Value *V, int ExtractIdx)
+ : V(V), ExtractIdx(ExtractIdx) {}
+ ExtractElementDescr(Value *V) : V(V), ExtractIdx(std::nullopt) {}
+ Value *getValue() const { return V; }
+ bool needsExtract() const { return ExtractIdx.has_value(); }
+ int getExtractIdx() const { return *ExtractIdx; }
+ };
+
+ using DescrVecT = SmallVector<ExtractElementDescr, 4>;
+ DescrVecT Descrs;
+
+public:
+ CollectDescr(SmallVectorImpl<ExtractElementDescr> &&Descrs)
+ : Descrs(std::move(Descrs)) {}
+ std::optional<std::pair<Value *, bool>> getSingleInput() const {
+ const auto &Descr0 = *Descrs.begin();
+ Value *V0 = Descr0.getValue();
+ if (!Descr0.needsExtract())
+ return std::nullopt;
+ bool NeedsShuffle = Descr0.getExtractIdx() != 0;
+ int Lane = 1;
+ for (const auto &Descr : drop_begin(Descrs)) {
+ if (!Descr.needsExtract())
+ return std::nullopt;
+ if (Descr.getValue() != V0)
+ return std::nullopt;
+ if (Descr.getExtractIdx() != Lane++)
+ NeedsShuffle = true;
+ }
+ return std::make_pair(V0, NeedsShuffle);
+ }
+ bool hasVectorInputs() const {
+ return any_of(Descrs, [](const auto &D) { return D.needsExtract(); });
+ }
+ const SmallVector<ExtractElementDescr, 4> &getDescrs() const {
+ return Descrs;
+ }
+};
+
/// Performs the legality analysis and returns a LegalityResult object.
class LegalityAnalysis {
Scheduler Sched;
@@ -160,11 +228,17 @@ class LegalityAnalysis {
ScalarEvolution &SE;
const DataLayout &DL;
+ InstrMaps &IMaps;
+
+ /// Finds how we can collect the values in \p Bndl from the vectorized or
+ /// non-vectorized code. It returns a map of the value we should extract from
+ /// and the corresponding shuffle mask we need to use.
+ CollectDescr getHowToCollectValues(ArrayRef<Value *> Bndl) const;
public:
LegalityAnalysis(AAResults &AA, ScalarEvolution &SE, const DataLayout &DL,
- Context &Ctx)
- : Sched(AA, Ctx), SE(SE), DL(DL) {}
+ Context &Ctx, InstrMaps &IMaps)
+ : Sched(AA, Ctx), SE(SE), DL(DL), IMaps(IMaps) {}
/// A LegalityResult factory.
template <typename ResultT, typename... ArgsT>
ResultT &createLegalityResult(ArgsT... Args) {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index 1a53ca6e06f5fd..69cea3c4c7b53b 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -18,6 +18,7 @@
#include "llvm/SandboxIR/Pass.h"
#include "llvm/SandboxIR/PassManager.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h"
namespace llvm::sandboxir {
@@ -26,6 +27,8 @@ class BottomUpVec final : public FunctionPass {
bool Change = false;
std::unique_ptr<LegalityAnalysis> Legality;
DenseSet<Instruction *> DeadInstrCandidates;
+ /// Maps scalars to vectors.
+ InstrMaps IMaps;
/// Creates and returns a vector instruction that replaces the instructions in
/// \p Bndl. \p Operands are the already vectorized operands.
diff --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index d769d5100afd23..6a025652f92f8e 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMVectorize
LoopVectorizationLegality.cpp
LoopVectorize.cpp
SandboxVectorizer/DependencyGraph.cpp
+ SandboxVectorizer/InstrMaps.cpp
SandboxVectorizer/Interval.cpp
SandboxVectorizer/Legality.cpp
SandboxVectorizer/Passes/BottomUpVec.cpp
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp
new file mode 100644
index 00000000000000..5ebcf90e74255b
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/InstrMaps.cpp
@@ -0,0 +1,21 @@
+//===- InstructionMaps.cpp - Maps scalars to vectors and reverse ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
+#include "llvm/Support/Debug.h"
+
+namespace llvm::sandboxir {
+
+#ifndef NDEBUG
+void InstrMaps::dump() const {
+ dump(dbgs());
+ dbgs() << "\n";
+}
+#endif // NDEBUG
+
+} // namespace llvm::sandboxir
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index 8c6deeb7df249d..45acdf09f2f2c7 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -12,6 +12,7 @@
#include "llvm/SandboxIR/Utils.h"
#include "llvm/SandboxIR/Value.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/InstrMaps.h"
#include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h"
namespace llvm::sandboxir {
@@ -184,6 +185,22 @@ static void dumpBndl(ArrayRef<Value *> Bndl) {
}
#endif // NDEBUG
+CollectDescr
+LegalityAnalysis::getHowToCollectValues(ArrayRef<Value *> Bndl) const {
+ SmallVector<CollectDescr::ExtractElementDescr, 4> Vec;
+ Vec.reserve(Bndl.size());
+ for (auto [Lane, V] : enumerate(Bndl)) {
+ if (auto *VecOp = IMaps.getVectorForOrig(V)) {
+ // If there is a vector containing `V`, then get the lane it came from.
+ std::optional<int> ExtractIdxOpt = IMaps.getOrigLane(VecOp, V);
+ Vec.emplace_back(VecOp, ExtractIdxOpt ? *ExtractIdxOpt : -1);
+ } else {
+ Vec.emplace_back(V);
+ }
+ }
+ return CollectDescr(std::move(Vec));
+}
+
const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
bool SkipScheduling) {
// If Bndl contains values other than instructions, we need to Pack.
@@ -193,11 +210,21 @@ const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
return createLegalityResult<Pack>(ResultReason::NotInstructions);
}
+ auto CollectDescrs = getHowToCollectValues(Bndl);
+ if (CollectDescrs.hasVectorInputs()) {
+ if (auto ValueShuffleOpt = CollectDescrs.getSingleInput()) {
+ auto [Vec, NeedsShuffle] = *ValueShuffleOpt;
+ if (!NeedsShuffle)
+ return createLegalityResult<DiamondReuse>(Vec);
+ llvm_unreachable("TODO: Unimplemented");
+ } else {
+ llvm_unreachable("TODO: Unimplemented");
+ }
+ }
+
if (auto ReasonOpt = notVectorizableBasedOnOpcodesAndTypes(Bndl))
return createLegalityResult<Pack>(*ReasonOpt);
- // TODO: Check for existing vectors containing values in Bndl.
-
if (!SkipScheduling) {
// TODO: Try to remove the IBndl vector.
SmallVector<Instruction *, 8> IBndl;
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index d44199609838d7..6b2032be535603 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -56,103 +56,114 @@ getInsertPointAfterInstrs(ArrayRef<Value *> Instrs) {
Value *BottomUpVec::createVectorInstr(ArrayRef<Value *> Bndl,
ArrayRef<Value *> Operands) {
- Change = true;
- assert(all_of(Bndl, [](auto *V) { return isa<Instruction>(V); }) &&
- "Expect Instructions!");
- auto &Ctx = Bndl[0]->getContext();
+ auto CreateVectorInstr = [](ArrayRef<Value *> Bndl,
+ ArrayRef<Value *> Operands) -> Value * {
+ assert(all_of(Bndl, [](auto *V) { return isa<Instruction>(V); }) &&
+ "Expect Instructions!");
+ auto &Ctx = Bndl[0]->getContext();
- Type *ScalarTy = VecUtils::getElementType(Utils::getExpectedType(Bndl[0]));
- auto *VecTy = VecUtils::getWideType(ScalarTy, VecUtils::getNumLanes(Bndl));
+ Type *ScalarTy = VecUtils::getElementType(Utils::getExpectedType(Bndl[0]));
+ auto *VecTy = VecUtils::getWideType(ScalarTy, VecUtils::getNumLanes(Bndl));
- BasicBlock::iterator WhereIt = getInsertPointAfterInstrs(Bndl);
+ BasicBlock::iterator WhereIt = getInsertPointAfterInstrs(Bndl);
- auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
- switch (Opcode) {
- case Instruction::Opcode::ZExt:
- case Instruction::Opcode::SExt:
- case Instruction::Opcode::FPToUI:
- case Instruction::Opcode::FPToSI:
- case Instruction::Opcode::FPExt:
- case Instruction::Opcode::PtrToInt:
- case Instruction::Opcode::IntToPtr:
- case Instruction::Opcode::SIToFP:
- case Instruction::Opcode::UIToFP:
- case Instruction::Opcode::Trunc:
- case Instruction::Opcode::FPTrunc:
- case Instruction::Opcode::BitCast: {
- assert(Operands.size() == 1u && "Casts are unary!");
- return CastInst::create(VecTy, Opcode, Operands[0], WhereIt, Ctx, "VCast");
- }
- case Instruction::Opcode::FCmp:
- case Instruction::Opcode::ICmp: {
- auto Pred = cast<CmpInst>(Bndl[0])->getPredicate();
- assert(all_of(drop_begin(Bndl),
- [Pred](auto *SBV) {
- return cast<CmpInst>(SBV)->getPredicate() == Pred;
- }) &&
- "Expected same predicate across bundle.");
- return CmpInst::create(Pred, Operands[0], Operands[1], WhereIt, Ctx,
- "VCmp");
- }
- case Instruction::Opcode::Select: {
- return SelectInst::create(Operands[0], Operands[1], Operands[2], WhereIt,
- Ctx, "Vec");
- }
- case Instruction::Opcode::FNeg: {
- auto *UOp0 = cast<UnaryOperator>(Bndl[0]);
- auto OpC = UOp0->getOpcode();
- return UnaryOperator::createWithCopiedFlags(OpC, Operands[0], UOp0, WhereIt,
- Ctx, "Vec");
- }
- case Instruction::Opcode::Add:
- case Instruction::Opcode::FAdd:
- case Instruction::Opcode::Sub:
- case Instruction::Opcode::FSub:
- case Instruction::Opcode::Mul:
- case Instruction::Opcode::FMul:
- case Instruction::Opcode::UDiv:
- case Instruction::Opcode::SDiv:
- case Instruction::Opcode::FDiv:
- case Instruction::Opcode::URem:
- case Instruction::Opcode::SRem:
- case Instruction::Opcode::FRem:
- case Instruction::Opcode::Shl:
- case Instruction::Opcode::LShr:
- case Instruction::Opcode::AShr:
- case Instruction::Opcode::And:
- case Instruction::Opcode::Or:
- case Instruction::Opcode::Xor: {
- auto *BinOp0 = cast<BinaryOperator>(Bndl[0]);
- auto *LHS = Operands[0];
- auto *RHS = Operands[1];
- return BinaryOperator::createWithCopiedFlags(BinOp0->getOpcode(), LHS, RHS,
- BinOp0, WhereIt, Ctx, "Vec");
- }
- case Instruction::Opcode::Load: {
- auto *Ld0 = cast<LoadInst>(Bndl[0]);
- Value *Ptr = Ld0->getPointerOperand();
- return LoadInst::create(VecTy, Ptr, Ld0->getAlign(), WhereIt, Ctx, "VecL");
- }
- case Instruction::Opcode::Store: {
- auto Align = cast<StoreInst>(Bndl[0])->getAlign();
- Value *Val = Operands[0];
- Value *Ptr = Operands[1];
- return StoreInst::create(Val, Ptr, Align, WhereIt, Ctx);
- }
- case Instruction::Opcode::Br:
- case Instruction::Opcode::Ret:
- case Instruction::Opcode::PHI:
- case Instruction::Opcode::AddrSpaceCast:
- case Instruction::Opcode::Call:
- case Instruction::Opcode::GetElementPtr:
- llvm_unreachable("Unimplemented");
- break;
- default:
- llvm_unreachable("Unimplemented");
- break;
+ auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
+ switch (Opcode) {
+ case Instruction::Opcode::ZExt:
+ case Instruction::Opcode::SExt:
+ case Instruction::Opcode::FPToUI:
+ case Instruction::Opcode::FPToSI:
+ case Instruction::Opcode::FPExt:
+ case Instruction::Opcode::PtrToInt:
+ case Instruction::Opcode::IntToPtr:
+ case Instruction::Opcode::SIToFP:
+ case Instruction::Opcode::UIToFP:
+ case Instruction::Opcode::Trunc:
+ case Instruction::Opcode::FPTrunc:
+ case Instruction::Opcode::BitCast: {
+ assert(Operands.size() == 1u && "Casts are unary!");
+ return CastInst::create(VecTy, Opcode, Operands[0], WhereIt, Ctx,
+ "VCast");
+ }
+ case Instruction::Opcode::FCmp:
+ case Instruction::Opcode::ICmp: {
+ auto Pred = cast<CmpInst>(Bndl[0])->getPredicate();
+ assert(all_of(drop_begin(Bndl),
+ [Pred](auto *SBV) {
+ return cast<CmpInst>(SBV)->getPredicate() == Pred;
+ }) &&
+ "Expected same predicate across bundle.");
+ return CmpInst::create(Pred, Operands[0], Operands[1], WhereIt, Ctx,
+ "VCmp");
+ }
+ case Instruction::Opcode::Select: {
+ return SelectInst::create(Operands[0], Operands[1], Operands[2], WhereIt,
+ Ctx, "Vec");
+ }
+ case Instruction::Opcode::FNeg: {
+ auto *UOp0 = cast<UnaryOperator>(Bndl[0]);
+ auto OpC = UOp0->getOpcode();
+ return UnaryOperator::createWithCopiedFlags(OpC, Operands[0], UOp0,
+ WhereIt, Ctx, "Vec");
+ }
+ case Instruction::Opcode::Add:
+ case Instruction::Opcode::FAdd:
+ case Instruction::Opcode::Sub:
+ case Instruction::Opcode::FSub:
+ case Instruction::Opcode::Mul:
+ case Instruction::Opcode::FMul:
+ case Instruction::Opcode::UDiv:
+ case Instruction::Opcode::SDiv:
+ case Instruction::Opcode::FDiv:
+ case Instruction::Opcode::URem:
+ case Instruction::Opcode::SRem:
+ case Instruction::Opcode::FRem:
+ case Instruction::Opcode::Shl:
+ case Instruction::Opcode::LShr:
+ case Instruction::Opcode::AShr:
+ case Instruction::Opcode::And:
+ case Instruction::Opcode::Or:
+ case Instruction::Opcode::Xor: {
+ auto *BinOp0 = cast<BinaryOperator>(Bndl[0]);
+ auto *LHS = Operands[0];
+ auto *RHS = Operands[1];
+ return BinaryOperator::createWithCopiedFlags(
+ BinOp0->getOpcode(), LHS, RHS, BinOp0, WhereIt, Ctx, "Vec");
+ }
+ case Instruction::Opcode::Load: {
+ auto *Ld0 = cast<LoadInst>(Bndl[0]);
+ Value *Ptr = Ld0->getPointerOperand();
+ return LoadInst::create(VecTy, Ptr, Ld0->getAlign(), WhereIt, Ctx,
+ "VecL");
+ }
+ case Instruction::Opcode::Store: {
+ auto Align = cast<StoreInst>(Bndl[0])->getAlign();
+ Value *Val = Operan...
[truncated]
|
fbcc84a
to
693e4d0
Compare
@@ -0,0 +1,77 @@ | |||
//===- InstructionMaps.h ----------------------------------------*- C++ -*-===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the comment doesn't match the file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVEC_PASSES_INSTRUCTIONMAPS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The include guard also doesn't match the file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
DenseMap<Value *, DenseMap<Value *, unsigned>> VectorToOrigLaneMap; | ||
|
||
public: | ||
/// \Returns all the vector value that we got from vectorizing \p Orig, or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "all" here a typo? The function only returns one value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a typo, fixed.
} | ||
/// \Returns the lane of \p Orig before it got vectorized into \p Vec, or | ||
/// nullopt if not found. | ||
std::optional<int> getOrigLane(Value *Vec, Value *Orig) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lane is stored in the map as unsigned
but here we return an int
(wrapped in an optional
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it to optional.
InstrMaps is a helper data structure that maps scalars to vectors and the reverse. This is used by the vectorizer to figure out which vectors it can extract scalar values from.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/7595 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/4491 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2096 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/2004 Here is the relevant piece of the build log for the reference
|
InstrMaps is a helper data structure that maps scalars to vectors and the reverse. This is used by the vectorizer to figure out which vectors it can extract scalar values from.