Skip to content

Commit fad8e8d

Browse files
Merge pull request #419 from Wuerfel21/W32-whatever-this-is
Document more opt stuff and only allow pure inlining if constant propagation is actually enabled
2 parents fd03930 + 60ec71f commit fad8e8d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

backends/asm/optimize_ir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5445,6 +5445,7 @@ ShouldExpandPureFunction(IR *ir) {
54455445
Function *f = (Function *)ir->aux;
54465446
if (!(FuncData(f)->inliningFlags & ASM_INLINE_PURE_FLAG)) return false;
54475447
if (!(gl_optimize_flags & OPT_EXPERIMENTAL)) return false;
5448+
if (!(gl_optimize_flags & OPT_CONST_PROPAGATE)) return false;
54485449
if (f->numparams <= 0) return false;
54495450

54505451
// Make sure all args are constants

doc/general.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ Similarly use `__attribute__((lut))` to place the function into LUT memory.
143143

144144
### Small functions
145145

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).
147151

148152
### Forcing a function to be inline
149153

@@ -387,6 +391,7 @@ Optimizes some specialized function calls for common cases. For example, in the
387391

388392
pinread: Optimized if just one pin is read
389393
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)
390395

391396

392397
### Reorder instructions for Cordic (-O1, -Ocordic-reorder)
@@ -401,7 +406,7 @@ Enables some more aggressive optimizations which attempt to track values and red
401406

402407
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.
403408

404-
### Single Use Method inlining (-O2, -Oinline-single)
409+
### Single Use Method inlining (-O2, -Os, -Oinline-single)
405410

406411
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.
407412

@@ -436,6 +441,12 @@ is converted to the equivalent of
436441
bptr += 4
437442
```
438443

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+
439450
#### Multiply to addition
440451

441452
An expression like `(i*100)` where `i` is a loop index can be converted to

0 commit comments

Comments
 (0)