<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 11:25 AM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>On Thu, Dec 17, 2015 at 11:04 AM, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br>
> On Thu, Dec 17, 2015 at 12:05:46PM +0100, Glenn Kennard wrote:<br>
>> On Wed, 16 Dec 2015 20:57:51 +0100, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br>
>><br>
>> >From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
>> ><br>
>> >Commit 64880d073ab21ae1abad0c049ea2d6a1169a3cfa consolidated two<br>
>> >DIV_ROUND_UP() definitions to one, but chose the more<br>
>> >compute-intensive version in the process. Use the simpler version<br>
>> >instead. Reduces .text size by 1360 bytes.<br>
>> ><br>
>> >Output of `size lib/i965_dri.so`:<br>
>> > text data bss dec hex filename<br>
>> > 7850440 219264 27240 8096944 7b8cb0 lib/i965_dri.so (before)<br>
>> > 7849080 219264 27240 8095584 7b8760 lib/i965_dri.so (after)<br>
>> ><br>
>> >Cc: Axel Davy <<a href="mailto:axel.davy@ens.fr" target="_blank">axel.davy@ens.fr</a>><br>
>> >Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
>> >---<br>
>> > src/util/macros.h | 2 +-<br>
>> > 1 file changed, 1 insertion(+), 1 deletion(-)<br>
>> ><br>
>> >diff --git a/src/util/macros.h b/src/util/macros.h<br>
>> >index 0c8958f..53a98a0 100644<br>
>> >--- a/src/util/macros.h<br>
>> >+++ b/src/util/macros.h<br>
>> >@@ -211,6 +211,6 @@ do { \<br>
>> > #endif<br>
>> >/** Compute ceiling of integer quotient of A divided by B. */<br>
>> >-#define DIV_ROUND_UP( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )<br>
>> >+#define DIV_ROUND_UP(A, B) (((A) + (B) - 1) / (B))<br>
>> >#endif /* UTIL_MACROS_H */<br>
>><br>
>> I'll point out that these are not equivalent, one can overflow and the other doesn't. You<br>
>> probably want to check if the call sites have sufficient checks for that before<br>
>> substituting one for the other.<br>
>><br>
><br>
> Good point. As I mentioned in another email, I'll leave the current<br>
> macro untouched.<br>
<br></div></div></blockquote><div><br></div><div>The other email I referenced unfortunately didn't make it to the list due email client<br></div><div>issues.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>
</div></div>I think the chances of us relying on overflow behavior are exceedingly<br>
small, and nearly all uses of DIV_ROUND_UP are in the i965 driver. I<br>
think it's sufficiently safe to go ahead with the patch (but I am<br>
still interested to know about your compiler and CFLAGS).<br>
</blockquote></div><br></div><div class="gmail_extra">My error was that I forgot to remove --enable-debug and add -02. After making those <br>changes, my binary size also increases but by ~1.1k. Another implementation which<br>avoids overflow increases the binary size by 2 bytes.<br><br>Correct me if I'm wrong, but aligning w/ the kernel implementation (or changing the<br>current definition for that matter) seems like a regression more than an improvement. <br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks,<br></div><div class="gmail_extra">Nanley<br></div></div>