* src/SDCCast.c(decorateType): better optimize '!!' and comparisons
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 4 Jun 2007 20:46:17 +0000 (20:46 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 4 Jun 2007 20:46:17 +0000 (20:46 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4836 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCast.c

index eae599bfedbb1bf44eb342cb2703daf37479a913..5ea767000edf499cccb81a7a79fe0b938a859167 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-04 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCast.c(decorateType): better optimize '!!' and comparisons
+
 2007-06-04 Borut Razem <borut.razem AT siol.net>
 
        * configure.in, configure, config_vc.awk: sdcc version number is now
index 84bbdd8f67d8b0cffb202b0fd7a3383da8b9f725..a81dd39c904cb6f6062ff96b51f54d8c0d5df37f 100644 (file)
@@ -3646,8 +3646,13 @@ decorateType (ast * tree, RESULT_TYPE resultType)
         }
 
       /* if left is another '!' */
-      if (tree->left->opval.op == '!')
+      if (IS_AST_NOT_OPER (tree->left))
         {
+          if ((resultType == RESULT_TYPE_IFX) || (resultType == RESULT_TYPE_BIT))
+            {
+              /* remove double '!!X' by 'X' */
+              return tree->left->left;
+            }
           /* remove double '!!X' by 'X ? 1 : 0' */
           tree->opval.op = '?';
           tree->left  = tree->left->left;
@@ -4132,7 +4137,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           IS_LITERAL(RTYPE(tree))  &&
           ((int) floatFromVal (valFromType (RETYPE (tree)))) == 0)
         {
-          if (resultType == RESULT_TYPE_IFX)
+          if ((resultType == RESULT_TYPE_IFX) || (resultType == RESULT_TYPE_BIT))
             {
               /* the parent is an ifx: */
               /* if (unsigned value) */