Skip to content

Commit eb9f475

Browse files
committed
Revert "[SandboxVec][Legality] Reject non-instructions (#113190)"
This reverts commit 6c9bbbc.
1 parent 6c9bbbc commit eb9f475

File tree

4 files changed

+4
-39
lines changed

4 files changed

+4
-39
lines changed

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ enum class LegalityResultID {
2828

2929
/// The reason for vectorizing or not vectorizing.
3030
enum class ResultReason {
31-
NotInstructions,
3231
DiffOpcodes,
3332
DiffTypes,
3433
};
@@ -47,8 +46,6 @@ struct ToStr {
4746

4847
static const char *getVecReason(ResultReason Reason) {
4948
switch (Reason) {
50-
case ResultReason::NotInstructions:
51-
return "NotInstructions";
5249
case ResultReason::DiffOpcodes:
5350
return "DiffOpcodes";
5451
case ResultReason::DiffTypes:
@@ -70,10 +67,6 @@ class LegalityResult {
7067
LegalityResult(LegalityResultID ID) : ID(ID) {}
7168
friend class LegalityAnalysis;
7269

73-
/// We shouldn't need copies.
74-
LegalityResult(const LegalityResult &) = delete;
75-
LegalityResult &operator=(const LegalityResult &) = delete;
76-
7770
public:
7871
virtual ~LegalityResult() {}
7972
LegalityResultID getSubclassID() const { return ID; }
@@ -97,7 +90,6 @@ class LegalityResultWithReason : public LegalityResult {
9790
friend class Pack; // For constructor.
9891

9992
public:
100-
ResultReason getReason() const { return Reason; }
10193
#ifndef NDEBUG
10294
void print(raw_ostream &OS) const override {
10395
LegalityResult::print(OS);
@@ -146,7 +138,7 @@ class LegalityAnalysis {
146138
}
147139
/// Checks if it's legal to vectorize the instructions in \p Bndl.
148140
/// \Returns a LegalityResult object owned by LegalityAnalysis.
149-
const LegalityResult &canVectorize(ArrayRef<Value *> Bndl);
141+
LegalityResult &canVectorize(ArrayRef<Value *> Bndl);
150142
};
151143

152144
} // namespace llvm::sandboxir

llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h"
10-
#include "llvm/SandboxIR/Instruction.h"
11-
#include "llvm/SandboxIR/Utils.h"
1210
#include "llvm/SandboxIR/Value.h"
1311
#include "llvm/Support/Debug.h"
1412

1513
namespace llvm::sandboxir {
1614

17-
#define DEBUG_TYPE "SBVec:Legality"
18-
1915
#ifndef NDEBUG
2016
void LegalityResult::dump() const {
2117
print(dbgs());
@@ -30,19 +26,7 @@ LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(
3026
return std::nullopt;
3127
}
3228

33-
static void dumpBndl(ArrayRef<Value *> Bndl) {
34-
for (auto *V : Bndl)
35-
dbgs() << *V << "\n";
36-
}
37-
38-
const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl) {
39-
// If Bndl contains values other than instructions, we need to Pack.
40-
if (any_of(Bndl, [](auto *V) { return !isa<Instruction>(V); })) {
41-
LLVM_DEBUG(dbgs() << "Not vectorizing: Not Instructions:\n";
42-
dumpBndl(Bndl););
43-
return createLegalityResult<Pack>(ResultReason::NotInstructions);
44-
}
45-
29+
LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl) {
4630
if (auto ReasonOpt = notVectorizableBasedOnOpcodesAndTypes(Bndl))
4731
return createLegalityResult<Pack>(*ReasonOpt);
4832

llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static SmallVector<Value *, 4> getOperand(ArrayRef<Value *> Bndl,
4040
}
4141

4242
void BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl) {
43-
const auto &LegalityRes = Legality.canVectorize(Bndl);
43+
auto LegalityRes = Legality.canVectorize(Bndl);
4444
switch (LegalityRes.getSubclassID()) {
4545
case LegalityResultID::Widen: {
4646
auto *I = cast<Instruction>(Bndl[0]);

llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,8 @@ define void @foo(ptr %ptr) {
5252
auto *St1 = cast<sandboxir::StoreInst>(&*It++);
5353

5454
sandboxir::LegalityAnalysis Legality;
55-
const auto &Result = Legality.canVectorize({St0, St1});
55+
auto Result = Legality.canVectorize({St0, St1});
5656
EXPECT_TRUE(isa<sandboxir::Widen>(Result));
57-
58-
{
59-
// Check NotInstructions
60-
auto &Result = Legality.canVectorize({F, St0});
61-
EXPECT_TRUE(isa<sandboxir::Pack>(Result));
62-
EXPECT_EQ(cast<sandboxir::Pack>(Result).getReason(),
63-
sandboxir::ResultReason::NotInstructions);
64-
}
6557
}
6658

6759
#ifndef NDEBUG
@@ -76,9 +68,6 @@ TEST_F(LegalityTest, LegalityResultDump) {
7668
sandboxir::LegalityAnalysis Legality;
7769
EXPECT_TRUE(
7870
Matches(Legality.createLegalityResult<sandboxir::Widen>(), "Widen"));
79-
EXPECT_TRUE(Matches(Legality.createLegalityResult<sandboxir::Pack>(
80-
sandboxir::ResultReason::NotInstructions),
81-
"Pack Reason: NotInstructions"));
8271
EXPECT_TRUE(Matches(Legality.createLegalityResult<sandboxir::Pack>(
8372
sandboxir::ResultReason::DiffOpcodes),
8473
"Pack Reason: DiffOpcodes"));

0 commit comments

Comments
 (0)