From c5cd6e44028eaf11efc2cf4fc49c87101b49c97f Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Wed, 5 Mar 2025 08:21:54 +0700
Subject: [PATCH v12 6/6] Only inline for constant input (partial revert)

---
 src/include/port/pg_crc32c.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
index 26b676dddc9..01192831ca3 100644
--- a/src/include/port/pg_crc32c.h
+++ b/src/include/port/pg_crc32c.h
@@ -66,12 +66,11 @@ static inline
 pg_crc32c
 pg_comp_crc32c_dispatch(pg_crc32c crc, const void *data, size_t len)
 {
-	if (len < 64)
+	if (__builtin_constant_p(len) && len < 64)
 	{
 		/*
-		 * For small inputs, inline the computation to avoid the runtime
-		 * check. This also allows the compiler to unroll loops for constant
-		 * input.
+		 * For small constant inputs, inline the computation. This allows the
+		 * compiler to unroll loops.
 		 */
 		return pg_comp_crc32c_sse42_inline(crc, data, len);
 	}
-- 
2.48.1

