From 76cb876563d0e2a3c850b14ca68638be9f6124a0 Mon Sep 17 00:00:00 2001 From: Arjun P Date: Mon, 20 Sep 2021 13:09:05 +0530 Subject: [PATCH] [MLIR] Simplex::appendVariable: early return if count == 0 --- mlir/lib/Analysis/Presburger/Simplex.cpp | 2 ++ mlir/unittests/Analysis/Presburger/SimplexTest.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp index d97a46f2b811..26b4c60e3139 100644 --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -483,6 +483,8 @@ void Simplex::rollback(unsigned snapshot) { } void Simplex::appendVariable(unsigned count) { + if (count == 0) + return; var.reserve(var.size() + count); colUnknown.reserve(colUnknown.size() + count); for (unsigned i = 0; i < count; ++i) { diff --git a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp index d1bb6499c315..2f1ce819c672 100644 --- a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp +++ b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp @@ -388,6 +388,7 @@ TEST(SimplexTest, appendVariable) { unsigned snapshot1 = simplex.getSnapshot(); simplex.appendVariable(); + simplex.appendVariable(0); EXPECT_EQ(simplex.getNumVariables(), 2u); int64_t yMin = 2, yMax = 5;