From 9c1f16e0c496f60a6e49aa115b8819f4f3b2e585 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Mon, 4 Jun 2007 20:46:17 +0000 Subject: [PATCH] * src/SDCCast.c(decorateType): better optimize '!!' and comparisons git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4836 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++++ src/SDCCast.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eae599bf..5ea76700 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-06-04 Maarten Brock + + * src/SDCCast.c(decorateType): better optimize '!!' and comparisons + 2007-06-04 Borut Razem * configure.in, configure, config_vc.awk: sdcc version number is now diff --git a/src/SDCCast.c b/src/SDCCast.c index 84bbdd8f..a81dd39c 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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) */ -- 2.30.2