Skip to content

mlir/Presburger: optimize normalizeDiv when gcd=1 #97893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

artagnon
Copy link
Contributor

@artagnon artagnon commented Jul 6, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jul 6, 2024

@llvm/pr-subscribers-mlir-presburger

@llvm/pr-subscribers-mlir

Author: Ramkumar Ramachandra (artagnon)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/97893.diff

1 Files Affected:

  • (modified) mlir/lib/Analysis/Presburger/Utils.cpp (+2)
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;

@artagnon artagnon merged commit 64740ed into llvm:main Jul 8, 2024
10 checks passed
@artagnon artagnon deleted the normalizediv-optz branch July 8, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants