Minor optimization: don't sign-extend when casting from bit to int type, since a...
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 22:44:52 +0000 (22:44 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 22:44:52 +0000 (22:44 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@475 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/ds390/gen.c

index 31f57e0f5c2b6eef071ecb40970c06f5415d3597..7d3ccf893dd94dc4d5297c95acfefd41bb557371 100644 (file)
@@ -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);