File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
include/llvm/Transforms/Vectorize/SandboxVectorizer
unittests/Transforms/Vectorize/SandboxVectorizer Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,17 @@ class InstrInterval {
8080 assert ((FromI == ToI || FromI->comesBefore (ToI)) &&
8181 " FromI should come before TopI!" );
8282 }
83+ InstrInterval (ArrayRef<Instruction *> Instrs) {
84+ assert (!Instrs.empty () && " Expected non-empty Instrs!" );
85+ FromI = Instrs[0 ];
86+ ToI = Instrs[0 ];
87+ for (auto *I : drop_begin (Instrs)) {
88+ if (I->comesBefore (FromI))
89+ FromI = I;
90+ else if (ToI->comesBefore (I))
91+ ToI = I;
92+ }
93+ }
8394 bool empty () const {
8495 assert (((FromI == nullptr && ToI == nullptr ) ||
8596 (FromI != nullptr && ToI != nullptr )) &&
@@ -92,6 +103,8 @@ class InstrInterval {
92103 return (FromI == I || FromI->comesBefore (I)) &&
93104 (I == ToI || I->comesBefore (ToI));
94105 }
106+ Instruction *top () const { return FromI; }
107+ Instruction *bottom () const { return ToI; }
95108
96109 using iterator =
97110 InstrIntervalIterator<sandboxir::Instruction &, InstrInterval>;
Original file line number Diff line number Diff line change @@ -50,6 +50,26 @@ define void @foo(i8 %v0) {
5050#ifndef NDEBUG
5151 EXPECT_DEATH (sandboxir::InstrInterval (I1, I0), " .*before.*" );
5252#endif // NDEBUG
53+ // Check InstrInterval(ArrayRef), from(), to().
54+ {
55+ sandboxir::InstrInterval Interval (
56+ SmallVector<sandboxir::Instruction *>({I0, Ret}));
57+ EXPECT_EQ (Interval.top (), I0);
58+ EXPECT_EQ (Interval.bottom (), Ret);
59+ }
60+ {
61+ sandboxir::InstrInterval Interval (
62+ SmallVector<sandboxir::Instruction *>({Ret, I0}));
63+ EXPECT_EQ (Interval.top (), I0);
64+ EXPECT_EQ (Interval.bottom (), Ret);
65+ }
66+ {
67+ sandboxir::InstrInterval Interval (
68+ SmallVector<sandboxir::Instruction *>({I0, I0}));
69+ EXPECT_EQ (Interval.top (), I0);
70+ EXPECT_EQ (Interval.bottom (), I0);
71+ }
72+
5373 // Check empty().
5474 EXPECT_FALSE (Interval.empty ());
5575 sandboxir::InstrInterval Empty;
You can’t perform that action at this time.
0 commit comments