[klibc] [klibc:master] [ARITH] Avoid imaxdiv when only one of the results is wanted

klibc-bot for Harald van Dijk harald at gigawatt.nl
Mon Jul 2 02:12:06 PDT 2012

Commit-ID:  4a12ba8937fbc47ee82ab76bd4fceddf6338dced
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=4a12ba8937fbc47ee82ab76bd4fceddf6338dced
Author:     Harald van Dijk <harald at gigawatt.nl>
AuthorDate: Wed, 17 Aug 2011 09:28:24 +0800
Committer:  maximilian attems <max at stro.at>
CommitDate: Mon, 2 Jul 2012 10:46:06 +0200

[klibc] [ARITH] Avoid imaxdiv when only one of the results is wanted

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 at gigawatt.nl>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: maximilian attems <max at stro.at>

 usr/dash/arith_yacc.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/usr/dash/arith_yacc.c b/usr/dash/arith_yacc.c
index bf21830..1a087c3 100644
--- a/usr/dash/arith_yacc.c
+++ b/usr/dash/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)
-	imaxdiv_t div;
 	switch (op) {
 	case ARITH_REM:
 	case ARITH_DIV:
 		if (!b)
 			yyerror("division by zero");
-		div = imaxdiv(a, b);
-		return op == ARITH_REM ? div.rem : div.quot;
 		return op == ARITH_REM ? a % b : a / b;
 	case ARITH_MUL:
 		return a * b;
 	case ARITH_ADD:

More information about the klibc mailing list