From: SourceForge.net <no...@so...> - 2007-10-13 09:40:33
|
Feature Requests item #1738430, was opened at 2007-06-16 19:49 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1738430&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Private: No Submitted By: Hubert Sack (hsack) Assigned to: Nobody/Anonymous (nobody) Summary: tri-ops again Initial Comment: I detected in the actual version 4854 that it produces unneeded slocs if the result is a bit and the literals after ? and : are bits too. I attached a smal source file where it can be reproduced ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2007-10-13 11:40 Message: Logged In: YES user_id=888171 Originator: NO I ran the regression tests with the exception made by Sandeep disabled and found something. Have a look at this: char *str = 1 ? NULL : "never"; When the right side is decorated before the condition is evaluated the constant string "never" is put in code anyway. The same is true btw. for the following code. void foo(void) { char *str = "unused"; } There is no code generated for the assignment and no space allocated for str, but the (unused) constant string IS put in the CONST segment. And that is how one feature request becomes a totally different one. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2007-09-06 17:54 Message: Logged In: YES user_id=888171 Originator: NO I was looking into this further, but I am stuck now. The casts on the literals are not yet replaced by a new literal of the casted type because the ':' part is not decorated yet. And this is done on purpose by a change to SDCCast.c made by Sandeep in revision 1627. His comment, which I do not understand, is: /* delay right side for '?' operator since conditional macro expansions might rely on this */ Can anyone shed some light on this? Maarten ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2007-09-06 14:28 Message: Logged In: YES user_id=888171 Originator: NO This should be a more generic request: For any assignment from a tri-op a temporary is used which most of the time can be avoided. The temporary can be in registers or an sloc. Only one special case where the result is a bit and the two operands are literals is currently optimized. long i; char c; bit b; void test(unsigned char x) { b = (x<1) ? 1 : 0; // only this goes without iTemp b = (x<2) ? (bit)1 : (bit)0; // uses a bit sloc c = (x<3) ? 1 : 0; // uses a register c = (x<4) ? (char)1 : (char)0; // uses a register i = (x<5) ? 1 : 0; // uses a register i = (x<6) ? (long)1 : (long)0; // uses several registers } Maarten ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1738430&group_id=599 |