[llvm] [HashRecognize] Clarify hdr comment on GF(2^m) (NFC) (PR #157482)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 08:22:49 PDT 2025


https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/157482

>From ea914773714f22e2222dc1a2d2f8ead8c72cb96b Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 8 Sep 2025 15:47:43 +0100
Subject: [PATCH 1/2] [HashRecognize] Clarify hdr comment on GF(2^m) (NFC)

Unify explanation for GF(2^m) and GF(2), which was previously
convoluted.
---
 llvm/lib/Analysis/HashRecognize.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index 5b3448f5df35d..3eb6f0160cdaf 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -24,9 +24,8 @@
 //
 //    c_m * x^m + c_(m-1) * x^(m-1) + ... + c_0 * x^0
 //
-// where each coefficient c is can take values in GF(2^n), where 2^n is termed
-// the order of the Galois field. For GF(2), each coefficient can take values
-// either 0 or 1, and the polynomial is simply represented by m+1 bits,
+// where each coefficient c is can take values 0 or 1, and 2^n is termed the
+// order of the Galois field. The polynomial is simply represented by m+1 bits,
 // corresponding to the coefficients. The different variants of CRC are named by
 // degree of generating polynomial used: so CRC-32 would use a polynomial of
 // degree 32.

>From eb2a70d3c974cd24fb80d68740c09186a46839af Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 8 Sep 2025 16:21:57 +0100
Subject: [PATCH 2/2] [HashRecognize] Fix dangling n ref

---
 llvm/lib/Analysis/HashRecognize.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index 3eb6f0160cdaf..3a3530c60c458 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -8,8 +8,10 @@
 //
 // The HashRecognize analysis recognizes unoptimized polynomial hash functions
 // with operations over a Galois field of characteristic 2, also called binary
-// fields, or GF(2^n): this class of hash functions can be optimized using a
-// lookup-table-driven implementation, or with target-specific instructions.
+// fields, or GF(2^n). 2^n is termed the order of the Galois field. This class
+// of hash functions can be optimized using a lookup-table-driven
+// implementation, or with target-specific instructions.
+//
 // Examples:
 //
 //  1. Cyclic redundancy check (CRC), which is a polynomial division in GF(2).
@@ -24,11 +26,10 @@
 //
 //    c_m * x^m + c_(m-1) * x^(m-1) + ... + c_0 * x^0
 //
-// where each coefficient c is can take values 0 or 1, and 2^n is termed the
-// order of the Galois field. The polynomial is simply represented by m+1 bits,
-// corresponding to the coefficients. The different variants of CRC are named by
-// degree of generating polynomial used: so CRC-32 would use a polynomial of
-// degree 32.
+// where each coefficient c is can take values 0 or 1. The polynomial is simply
+// represented by m+1 bits, corresponding to the coefficients. The different
+// variants of CRC are named by degree of generating polynomial used: so CRC-32
+// would use a polynomial of degree 32.
 //
 // The reason algorithms on GF(2^n) can be optimized with a lookup-table is the
 // following: in such fields, polynomial addition and subtraction are identical



More information about the llvm-commits mailing list