[Mesa-dev] [PATCH] util/macros: Simplify DIV_ROUND_UP() definition

Nanley Chery nanleychery at gmail.com
Wed Dec 16 11:57:51 PST 2015


From: Nanley Chery <nanley.g.chery at intel.com>

Commit 64880d073ab21ae1abad0c049ea2d6a1169a3cfa consolidated two
DIV_ROUND_UP() definitions to one, but chose the more
compute-intensive version in the process. Use the simpler version
instead. Reduces .text size by 1360 bytes.

Output of `size lib/i965_dri.so`:
      text    data     bss     dec     hex filename
   7850440  219264   27240 8096944  7b8cb0 lib/i965_dri.so (before)
   7849080  219264   27240 8095584  7b8760 lib/i965_dri.so (after)

Cc: Axel Davy <axel.davy at ens.fr>
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/util/macros.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/macros.h b/src/util/macros.h
index 0c8958f..53a98a0 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -211,6 +211,6 @@ do {                       \
 #endif
 
 /** Compute ceiling of integer quotient of A divided by B. */
-#define DIV_ROUND_UP( A, B )  ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+#define DIV_ROUND_UP(A, B)  (((A) + (B) - 1) / (B))
 
 #endif /* UTIL_MACROS_H */
-- 
2.6.4



More information about the mesa-dev mailing list