All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Avoid imaxdiv when only one of the results is wanted
@ 2011-07-25 23:09 Harald van Dijk
  2011-07-26  0:26 ` Harald van Dijk
  2011-08-17  1:27 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Harald van Dijk @ 2011-07-25 23:09 UTC (permalink / raw)
  To: dash

dash rather pointlessly calls imaxdiv, only to discard one of its
results. The call was already made conditional a while back because some
systems don't have imaxdiv, but the generated code for the version with
imaxdiv and the one with / and % is identical (with GCC 4.6.1 or ICC
12.0.2, with -O0, -O2 or -Os), so it could just as well go entirely to
clean up the code a little bit.

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>

diff --git a/ChangeLog b/ChangeLog
index b96e5b2..02bfda0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-26  Harald van Dijk <harald@gigawatt.nl>
+
+	* Avoid imaxdiv when only one of the results is wanted.
+
 2010-07-09  maximilian attems <max@stro.at>
 
 	* Fix klibc DEBUG compilation.
diff --git a/configure.ac b/configure.ac
index 7eae954..5cd6e95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,7 +85,7 @@ AC_CHECK_DECL([PRIdMAX],,
 ])
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit imaxdiv isalpha
killpg \
+AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \
 	       mempcpy \
 	       sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
 	       strtoumax sysconf)
diff --git a/src/arith_yacc.c b/src/arith_yacc.c
index bf21830..1a087c3 100644
--- a/src/arith_yacc.c
+++ b/src/arith_yacc.c
@@ -94,22 +94,13 @@ static inline int higher_prec(int op1, int op2)
 
 static intmax_t do_binop(int op, intmax_t a, intmax_t b)
 {
-#ifdef HAVE_IMAXDIV
-	imaxdiv_t div;
-#endif

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Avoid imaxdiv when only one of the results is wanted
  2011-07-25 23:09 [PATCH] Avoid imaxdiv when only one of the results is wanted Harald van Dijk
@ 2011-07-26  0:26 ` Harald van Dijk
  2011-08-17  1:27 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Harald van Dijk @ 2011-07-26  0:26 UTC (permalink / raw)
  To: dash

On Tue, 2011-07-26 at 01:09 +0200, Harald van Dijk wrote:
> dash rather pointlessly calls imaxdiv, only to discard one of its
> results. The call was already made conditional a while back because some
> systems don't have imaxdiv, but the generated code for the version with
> imaxdiv and the one with / and % is identical (with GCC 4.6.1 or ICC
> 12.0.2, with -O0, -O2 or -Os), so it could just as well go entirely to
> clean up the code a little bit.

As I should have expected from those results, I messed up on the
comparisons. I still had an alternate definition of imaxdiv I was
testing with. The size actually decreases with the patch.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Avoid imaxdiv when only one of the results is wanted
  2011-07-25 23:09 [PATCH] Avoid imaxdiv when only one of the results is wanted Harald van Dijk
  2011-07-26  0:26 ` Harald van Dijk
@ 2011-08-17  1:27 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2011-08-17  1:27 UTC (permalink / raw)
  To: Harald van Dijk; +Cc: dash

On Mon, Jul 25, 2011 at 11:09:36PM +0000, Harald van Dijk wrote:
> dash rather pointlessly calls imaxdiv, only to discard one of its
> results. The call was already made conditional a while back because some
> systems don't have imaxdiv, but the generated code for the version with
> imaxdiv and the one with / and % is identical (with GCC 4.6.1 or ICC
> 12.0.2, with -O0, -O2 or -Os), so it could just as well go entirely to
> clean up the code a little bit.
> 
> Signed-off-by: Harald van Dijk <harald@gigawatt.nl>

Nice work, patch applied.

Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-17  1:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 23:09 [PATCH] Avoid imaxdiv when only one of the results is wanted Harald van Dijk
2011-07-26  0:26 ` Harald van Dijk
2011-08-17  1:27 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.