[Mlir-commits] [mlir] 76cb876 - [MLIR] Simplex::appendVariable: early return if count == 0
Arjun P
llvmlistbot at llvm.org
Mon Sep 20 00:47:24 PDT 2021
Author: Arjun P
Date: 2021-09-20T13:16:56+05:30
New Revision: 76cb876563d0e2a3c850b14ca68638be9f6124a0
URL: https://github.com/llvm/llvm-project/commit/76cb876563d0e2a3c850b14ca68638be9f6124a0
DIFF: https://github.com/llvm/llvm-project/commit/76cb876563d0e2a3c850b14ca68638be9f6124a0.diff
LOG: [MLIR] Simplex::appendVariable: early return if count == 0
Added:
Modified:
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/unittests/Analysis/Presburger/SimplexTest.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index d97a46f2b811e..26b4c60e31399 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 d1bb6499c3153..2f1ce819c6725 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;
More information about the Mlir-commits
mailing list