From: epetrich Date: Sat, 16 Jul 2005 03:36:25 +0000 (+0000) Subject: * src/SDCCcse.c (algebraicOpts): fixed loss of volatility X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=1fe6dcfaa0ec9449238f2cfe84ca47650e28d290;p=fw%2Fsdcc * src/SDCCcse.c (algebraicOpts): fixed loss of volatility for fields at offset 0 of a struct or union as reported on 2005-07-07 in the developer mailing list. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3803 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index b4ab4ce2..b6e9d1d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-07-16 Erik Petrich + + * src/SDCCcse.c (algebraicOpts): fixed loss of volatility + for fields at offset 0 of a struct or union as reported + on 2005-07-07 in the developer mailing list. + 2005-07-15 Maarten Brock * src/SDCCmem.c: fixed bug 1238386 diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 83863baa..8e68739e 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -829,8 +829,10 @@ algebraicOpts (iCode * ic, eBBlock * ebp) if (IS_OP_LITERAL (IC_LEFT (ic)) && operandLitValue (IC_LEFT (ic)) == 0.0) { - if (compareType (operandType (IC_RESULT (ic)), - operandType (IC_RIGHT (ic)))<0) + int typematch; + typematch = compareType (operandType (IC_RESULT (ic)), + operandType (IC_RIGHT (ic))); + if (typematch<0) { ic->op = CAST; IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic))); @@ -839,6 +841,12 @@ algebraicOpts (iCode * ic, eBBlock * ebp) { ic->op = '='; IC_LEFT (ic) = NULL; + if (typematch==0) + { + /* for completely different types, preserve the source type */ + IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic)); + setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic))); + } } SET_ISADDR (IC_RESULT (ic), 0); SET_ISADDR (IC_RIGHT (ic), 0); @@ -847,8 +855,10 @@ algebraicOpts (iCode * ic, eBBlock * ebp) if (IS_OP_LITERAL (IC_RIGHT (ic)) && operandLitValue (IC_RIGHT (ic)) == 0.0) { - if (compareType (operandType (IC_RESULT (ic)), - operandType (IC_LEFT (ic)))<0) + int typematch; + typematch = compareType (operandType (IC_RESULT (ic)), + operandType (IC_LEFT (ic))); + if (typematch<0) { ic->op = CAST; IC_RIGHT (ic) = IC_LEFT (ic); @@ -859,6 +869,12 @@ algebraicOpts (iCode * ic, eBBlock * ebp) ic->op = '='; IC_RIGHT (ic) = IC_LEFT (ic); IC_LEFT (ic) = NULL; + if (typematch==0) + { + /* for completely different types, preserve the source type */ + IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic)); + setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic))); + } } SET_ISADDR (IC_RIGHT (ic), 0); SET_ISADDR (IC_RESULT (ic), 0);