From: sandeep Date: Wed, 30 Jan 2002 04:35:18 +0000 (+0000) Subject: added some pointer arithmetic optimizations but not stable yet so not X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4340d183be0dac02574422be8ee91559af784fa8;p=fw%2Fsdcc added some pointer arithmetic optimizations but not stable yet so not called from anywhere (will get this working shortly) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1867 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCptropt.c b/src/SDCCptropt.c index 1db821d6..3660bb7f 100644 --- a/src/SDCCptropt.c +++ b/src/SDCCptropt.c @@ -173,7 +173,6 @@ static int pattern2 (iCode *sic) pgs->next = sh; sh->prev = pgs; return 1; - return 1; } /*-----------------------------------------------------------------------*/ @@ -186,3 +185,36 @@ ptrPostIncDecOpt (iCode * sic) if (pattern1(sic)) return ; pattern2(sic); } + +/*-----------------------------------------------------------------------*/ +/* addPattern1 - transform addition to pointer of variables */ +/*-----------------------------------------------------------------------*/ +static int addPattern1(iCode *ic) +{ + iCode *dic; + operand *tmp; + /* transform : + iTempAA = iTempBB + iTempCC + iTempDD = iTempAA + CONST + to + iTempAA = iTempBB + CONST + iTempDD = iTempAA + iTempCC + */ + if (!isOperandLiteral(IC_RIGHT(ic))) return 0; + if ((dic=findBackwardDef(IC_LEFT(ic),ic->prev)) == NULL) return 0; + if (bitVectnBitsOn(OP_SYMBOL(IC_RESULT(dic))->uses) > 1) return 0; + if (dic->op != '+') return 0; + tmp = IC_RIGHT(ic); + IC_RIGHT(ic) = IC_RIGHT(dic); + IC_RIGHT(dic) = tmp; + return 1; +} + +/*-----------------------------------------------------------------------*/ +/* ptrAddition - optimize pointer additions */ +/*-----------------------------------------------------------------------*/ +int ptrAddition (iCode *sic) +{ + if (addPattern1(sic)) return 1; + return 0; +}