-Oilib: Optimize Library Functions

Group

OPTIMIZATIONS

Scope

Function

Syntax
-Oilib[=<arguments>] 
Arguments

<arguments> are one or several of the following suboptions:

b: inline calls to strlen()

d: inline calls to fabs() or fabsf()

e: inline calls to memset()

f: inline calls to memcpy()

g: replace shifts left of 1 by array lookup

Default

None

Defines

None

Pragmas

None

Description

This option enables the compiler to optimize specific known library functions to reduce execution time. The Compiler frequently uses small functions such as strcpy(), strcmp(), and so forth. The following functions are optimized:

_PowOfTwo_8[val] replaces (char)1 << val if _PowOfTwo_8 is known at compile time. Similarly, for 16-bit and for 32-bit shifts, the arrays _PowOfTwo_16 and _PowOfTwo_32 are used. These constant arrays contain the values 1, 2, 4, 8.... They are declared in hidef.h. The compiler performs this optimization only when optimizing for time.

Using-Oilib without arguments optimizes calls to all supported library functions.

Example

The example code below compiles the function f with the -Oilib=a option (only available for ICG-based backends)

void f(void) {

  char *s = strcpy(s, ct);

}

This translates in a similar fashion to the following function:

void g(void) {

  s2 = s;

  while(*s2++ = *ct++);

}

See also

-Oi: Inlining

Message C5920