From 9fd013d9673ce2efe6f199f863e4f514d585eb03 Mon Sep 17 00:00:00 2001 From: kvigor Date: Tue, 17 Oct 2000 22:44:52 +0000 Subject: [PATCH] Minor optimization: don't sign-extend when casting from bit to int type, since a bit variable can't possible set the sign bit in a byte. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@475 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/ds390/gen.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 31f57e0f..7d3ccf89 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -8236,10 +8236,18 @@ static void genCast (iCode *ic) /* now depending on the sign of the source && destination */ size = AOP_SIZE(result) - AOP_SIZE(right); /* if unsigned or not an integral type */ - if (SPEC_USIGN(rtype) || !IS_SPEC(rtype)) { + /* also, if the source is a bit, we don't need to sign extend, because + * it can't possibly have set the sign bit. + */ + if (SPEC_USIGN(rtype) || !IS_SPEC(rtype) || AOP_TYPE(right) == AOP_CRY) + { while (size--) + { aopPut(AOP(result),zero,offset++); - } else { + } + } + else + { /* we need to extend the sign :{ */ char *l = aopGet(AOP(right),AOP_SIZE(right) - 1, FALSE,FALSE,TRUE); -- 2.47.2