Skip to content

Commit 9ca7a24

Browse files
authored
Add a compiler flag for the evaluateBuiltins pass (#6450)
1 parent 8a98de0 commit 9ca7a24

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/docusaurus/docs/delve-deeper/plutus-tx-compiler-options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For each boolean option, you can add a `no-` prefix to switch it off, such as `n
2020

2121
|Option|Value Type|Default|Description|
2222
|-|-|-|-|
23-
|`conservative-optimisation`|Bool|False|When conservative optimisation is used, only the optimisations that never make the program worse (in terms of cost or size) are employed. Implies `no-relaxed-float-in`, `no-inline-constants`, and `preserve-logging`.|
23+
|`conservative-optimisation`|Bool|False|When conservative optimisation is used, only the optimisations that never make the program worse (in terms of cost or size) are employed. Implies `no-relaxed-float-in`, `no-inline-constants`, `no-simplifier-evaluate-builtins`, and `preserve-logging`.|
2424
|`context-level`|Int|1|Set context level for error messages.|
2525
|`coverage-all`|Bool|False|Add all available coverage annotations in the trace output|
2626
|`coverage-boolean`|Bool|False|Add boolean coverage annotations in the trace output|
@@ -41,6 +41,7 @@ For each boolean option, you can add a `no-` prefix to switch it off, such as `n
4141
|`relaxed-float-in`|Bool|True|Use a more aggressive float-in pass, which often leads to reduced costs but may occasionally lead to slightly increased costs. Implied by `no-conservative-optimisation`.|
4242
|`remove-trace`|Bool|False|Eliminate calls to `trace` from Plutus Core|
4343
|`simplifier-beta`|Bool|True|Run a simplification pass that performs beta transformations|
44+
|`simplifier-evaluate-builtins`|Bool|True|Run a simplification pass that evaluates fully saturated builtin applications. Implied by `no-conservative-optimisation`.|
4445
|`simplifier-inline`|Bool|True|Run a simplification pass that performs inlining|
4546
|`simplifier-remove-dead-bindings`|Bool|True|Run a simplification pass that removes dead bindings|
4647
|`simplifier-unwrap-cancel`|Bool|True|Run a simplification pass that cancels unwrap/wrap pairs|
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
### Added
3+
4+
- A compiler flag `simplifier-evaluate-builtins` that controls whether to run the simplifier pass that evaluates fully saturated builtins at compile time.

plutus-tx-plugin/src/PlutusTx/Options.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ pluginOptions =
157157
desc =
158158
"When conservative optimisation is used, only the optimisations that \
159159
\never make the program worse (in terms of cost or size) are employed. \
160-
\Implies `no-relaxed-float-in`, `no-inline-constants`, and \
161-
\`preserve-logging`."
160+
\Implies `no-relaxed-float-in`, `no-inline-constants`, \
161+
\`no-simplifier-evaluate-builtins`, and `preserve-logging`."
162162
in ( k
163163
, PluginOption
164164
typeRep
@@ -171,10 +171,12 @@ pluginOptions =
171171
, Implication (== True) posPreserveLogging True
172172
, Implication (== True) posCaseOfCaseConservative True
173173
, Implication (== True) posInlineConstants False
174+
, Implication (== True) posDoSimplifierEvaluateBuiltins False
174175
, Implication (== False) posRelaxedFloatin True
175176
, Implication (== False) posPreserveLogging False
176177
, Implication (== False) posCaseOfCaseConservative False
177178
, Implication (== False) posInlineConstants True
179+
, Implication (== False) posDoSimplifierEvaluateBuiltins True
178180
]
179181
)
180182
, let k = "context-level"
@@ -230,6 +232,11 @@ pluginOptions =
230232
, let k = "simplifier-beta"
231233
desc = "Run a simplification pass that performs beta transformations"
232234
in (k, PluginOption typeRep (setTrue k) posDoSimplifierBeta desc [])
235+
, let k = "simplifier-evaluate-builtins"
236+
desc =
237+
"Run a simplification pass that evaluates fully saturated builtin applications. \
238+
\Implied by `no-conservative-optimisation`."
239+
in (k, PluginOption typeRep (setTrue k) posDoSimplifierEvaluateBuiltins desc [])
233240
, let k = "simplifier-inline"
234241
desc = "Run a simplification pass that performs inlining"
235242
in (k, PluginOption typeRep (setTrue k) posDoSimplifierInline desc [])

0 commit comments

Comments
 (0)