djulien 0 Posted August 17, 2012 Report Share Posted August 17, 2012 (edited) Bug description: Unneeded extra instructions and a temp are being generated for a chained bit set. See sample code below. #include <system.h> #define TRUE 1 volatile unsigned char var1, var2; #define bit1 var2.1 #define bit2 var2.2 inline void test(void) { if (var1 == 0xaa) bit1 = bit2 = TRUE; } void main(void) { test(); } code generated for test(): MOVF gbl_var1, W XORLW 0xAA BTFSS STATUS,Z ;//this compare is correct RETURN ;//okay until here CLRF CompTempVar560 INCF CompTempVar560, F ;//this temp is not needed BSF gbl_var2,2 ;//this instruction is correct BTFSC CompTempVar560,0 ;//this bit test is not needed; RHS was a const BSF gbl_var2,1 ;//this instruction is correct BTFSS CompTempVar560,0 ;//this bit test is also not needed BCF gbl_var2,1; //this instruction not needed RETURN The temp is not needed because the RHS was a const. The first bit test on the temp is not needed. The second bit test is alse inefficient; rather than "btfsc, bsf, btfss, bcf" it should have been "bsf, btfss, bcf" (if it had been needed at all). Expected behaviour: 1. Don't use a temp. 2. Eliminate (or at least reduce) the number of bit tests (none were needed in this case). Is the problem 100% reproduceable: yes Compiler: BoostC Compiler version: 7.10 (I didn't test prior to that) Target device: PIC16F1827, '1823, '688, etc. OS: Windows XP don Edited August 17, 2012 by djulien Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.