12.07.2015 Views

MPLAB C32 C COMPILER USER'S GUIDE

MPLAB C32 C COMPILER USER'S GUIDE

MPLAB C32 C COMPILER USER'S GUIDE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>MPLAB</strong> ® <strong>C32</strong> C Compiler User’s GuideTABLE 1-9:Option-fstrict-aliasingSPECIFIC OPTIMIZATION OPTIONS (CONTINUED)DefinitionAllows the compiler to assume the strictest aliasing rulesapplicable to the language being compiled. For C, thisactivates optimizations based on the type of expressions. Inparticular, an object of one type is assumed never to reside atthe same address as an object of a different type, unless thetypes are almost the same. For example, an unsigned intcan alias an int, but not a void* or a double. A charactertype may alias any other type.Pay special attention to code like this:union a_union {int i;double d;};-fthread-jumps-funroll-loops-funroll-all-loopsint f() {union a_union t;t.d = 3.0;return t.i;}The practice of reading from a different union member thanthe one most recently written to (called “type-punning”) iscommon. Even with -fstrict-aliasing, type-punning isallowed, provided the memory is accessed through the uniontype. So, the code above works as expected. However, thiscode might not:int f() {a_union t;int* ip;t.d = 3.0;ip = &t.i;return *ip;}Perform optimizations where a check is made to see if a jumpbranches to a location where another comparison subsumedby the first is found. If so, the first branch is redirected to eitherthe destination of the second branch or a point immediatelyfollowing it, depending on whether the condition is known tobe true or false.Perform the optimization of loop unrolling. This is only donefor loops whose number of iterations can be determined atcompile time or runtime. -funroll-loops implies both-fstrength-reduce and -frerun-cse-after-loop.Perform the optimization of loop unrolling. This is done for allloops and usually makes programs run more slowly.-funroll-all-loops implies -fstrength-reduce, aswell as -frerun-cse-after-loop.DS51686A-page 30© 2007 Microchip Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!