Search the Community
Showing results for tags 'optimization'.
Dear all, Two questions about how to optimize a for loop when compiling with the BoostC compiler. 1) Let's say I want to iterate over a value 'x' from 0 to a limit. I've been taught it's the best way to calculate the max. limit before entering the loop when using the C++ Borland compiler. Then the compiler won't need to execute the right operand of the conditional expression (calling a function xvalue() + adding one) hence improving execution time. // The best way when using a Borland C++ compiler like I've been taught unsigned int limit = xvalue() + 1; // where '+1' is the calculati
How can I implement a very efficient "jump table" using BoostC? I am trying to implement a jump table equivalent to this (the code needs to be fast): pcl += value; goto label1; goto label2; goto label3; etc. I've run into several issues: 1. First I tried function pointers, but they generate bulky code so now I am just trying to add an offset to pcl which will skip to a goto 2. The compiler is removing what it thinks is "dead code" (after the first goto), even with optimization turned off ("-O0") 3. After it removes the "dead code" gotos, it sees unreachable code (the ta
Bug description: Optimization is leaving extra instructions in the example cases below. Steps to reproduce: Example 1: unsigned char var1, var2; var1 = var2 = 0; code generated: clrf var1 movlw 0 ;this instr is not needed clrf var2 Example 2: unsigned char var3, var4, var5; var3 = 3; var4 = var3; var5 = var3 + var4; code generated: movlw 3 movwf var3 movf var3, w ;this instr is not needed movwf var4 movf var4, w ;this instr is not needed addwf var3, w movwf var5 Expected behaviour: Example 1: clrf var1 clrf var2 Example 2: