[MLIR] Simplex::appendVariable: early return if count == 0
authorArjun P <arjunpitchanathan@gmail.com>
Mon, 20 Sep 2021 07:39:05 +0000 (13:09 +0530)
committerArjun P <arjunpitchanathan@gmail.com>
Mon, 20 Sep 2021 07:46:56 +0000 (13:16 +0530)
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/unittests/Analysis/Presburger/SimplexTest.cpp

index d97a46f..26b4c60 100644 (file)
@@ -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) {
index d1bb649..2f1ce81 100644 (file)
@@ -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;