[Mlir-commits] [mlir] mlir/Presburger: optimize normalizeDiv when gcd=1 (PR #97893)

Ramkumar Ramachandra llvmlistbot at llvm.org
Sat Jul 6 05:16:37 PDT 2024


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/97893

None

>From c62972ba6f14981c686d59738b413272d2771e9f Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Sat, 6 Jul 2024 13:12:47 +0100
Subject: [PATCH] mlir/Presburger: optimize normalizeDiv when gcd=1

---
 mlir/lib/Analysis/Presburger/Utils.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 9b32972de2e0a..383888c3b5660 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -362,6 +362,8 @@ void presburger::normalizeDiv(MutableArrayRef<DynamicAPInt> num,
                               DynamicAPInt &denom) {
   assert(denom > 0 && "denom must be positive!");
   DynamicAPInt gcd = llvm::gcd(gcdRange(num), denom);
+  if (gcd == 1)
+    return;
   for (DynamicAPInt &coeff : num)
     coeff /= gcd;
   denom /= gcd;



More information about the Mlir-commits mailing list