Skip to content

Commit 76cb876

Browse files
committed
[MLIR] Simplex::appendVariable: early return if count == 0
1 parent ec03bbe commit 76cb876

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

mlir/lib/Analysis/Presburger/Simplex.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ void Simplex::rollback(unsigned snapshot) {
483483
}
484484

485485
void Simplex::appendVariable(unsigned count) {
486+
if (count == 0)
487+
return;
486488
var.reserve(var.size() + count);
487489
colUnknown.reserve(colUnknown.size() + count);
488490
for (unsigned i = 0; i < count; ++i) {

mlir/unittests/Analysis/Presburger/SimplexTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ TEST(SimplexTest, appendVariable) {
388388

389389
unsigned snapshot1 = simplex.getSnapshot();
390390
simplex.appendVariable();
391+
simplex.appendVariable(0);
391392
EXPECT_EQ(simplex.getNumVariables(), 2u);
392393

393394
int64_t yMin = 2, yMax = 5;

0 commit comments

Comments
 (0)