You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/general.md
+13-2Lines changed: 13 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,11 @@ Similarly use `__attribute__((lut))` to place the function into LUT memory.
143
143
144
144
### Small functions
145
145
146
-
Small functions are expanded inline (without a function call) if the `-Oinline-small` optimization is specified. This option is enabled at levels `-O1` and `-O2`. In this case "small" means just a few assembly language instructions are generated for it (2 instructions for P1, 4 instructions for P2 where memory is not quite so constrained).
146
+
Small functions are expanded inline (without a function call) if the `-Oinline-small` optimization is specified. This option is enabled at levels `-O1` and `-O2`. In this case "small" means just a few assembly language instructions are generated for it (~2 instructions for P1, ~4 instructions for P2 where memory is not quite so constrained and branches are more expensive). The limit is increased for functions that have many arguments.
147
+
148
+
### Pure functions
149
+
150
+
Pure functions (roughly considered as functions that only contain a certain subset of constant-propagateable instructions) are expanded inline and successively constant-propagated. This optimization is only performed when constant-propagation is enabled (see below) AND experimental optimizations are also enabled (see below, too).
147
151
148
152
### Forcing a function to be inline
149
153
@@ -387,6 +391,7 @@ Optimizes some specialized function calls for common cases. For example, in the
387
391
388
392
pinread: Optimized if just one pin is read
389
393
pinwrite: Optimized if just one pin or one bit are being written
394
+
memset: Optimized if fill length is constant and a multiple of 4 bytes (P2 only)
390
395
391
396
392
397
### Reorder instructions for Cordic (-O1, -Ocordic-reorder)
@@ -401,7 +406,7 @@ Enables some more aggressive optimizations which attempt to track values and red
401
406
402
407
Enables some miscellaneous optimizations that are new and hence slightly less well tested. Generally these should be pretty safe, but they're not quite ready for promotion to the default -O1.
403
408
404
-
### Single Use Method inlining (-O2, -Oinline-single)
409
+
### Single Use Method inlining (-O2, -Os, -Oinline-single)
405
410
406
411
If a method is called only once in a whole program, it is expanded inline at the call site, even if it is a fairly large method.
407
412
@@ -436,6 +441,12 @@ is converted to the equivalent of
436
441
bptr += 4
437
442
```
438
443
444
+
### Cold code (-Ocold-code)
445
+
446
+
Moves unlikely code paths (indicated using `__builtin_expect`) to the end of the function. This means the likely path can execute without taking any branches, in exchange for the unlikely path taking two branches. Also, due to outstanding refactoring of function epilogues, using this feature adds one taken branch when the function returns at its end.
447
+
448
+
This optimization is not currently enabled by any flags. Use it cautiously.
449
+
439
450
#### Multiply to addition
440
451
441
452
An expression like `(i*100)` where `i` is a loop index can be converted to
0 commit comments