From: SourceForge.net <no...@so...> - 2007-06-09 16:59:05
|
Patches item #1410855, was opened at 2006-01-20 15:46 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300599&aid=1410855&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: Closed >Resolution: Out of Date Priority: 5 Private: No Submitted By: Hubert Sack (hsack) >Assigned to: Maarten Brock (maartenbrock) Summary: trinary operator generates unnecessary operations Initial Comment: If the trinary operator is used and the destination is a bit, a lot of unnecessary operations are generated: #include <8051.h> #define LED_OFF 1 #define LED_ON 0 #define LED_at_Portpin P1_0 unsigned char value = 0; void main (void) { LED_at_Portpin = value < 2 ? LED_OFF : LED_ON; } The code doesn't become better if 0 and 1 is defined as false and true using stdbool.h In this case a additional sloc is generated. I solved this by adding 3 more peepholes. I think the solution can and should be made at icode level by anybody... ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2007-06-09 18:59 Message: Logged In: YES user_id=888171 Originator: NO SDCC 2.7.2 #4842 now generates the most compact code I can think of without peephole rules: mov a,#0x100 - 0x02 add a,_value mov _pin,c or if value is a parameter or local variable and in a register: cjne r2,#0x02,00105$ 00105$: mov _pin,c ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300599&aid=1410855&group_id=599 |