Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit f0781fe

Browse files
committed
Remove 'enable_constant_folding' setting and move into optimize method
1 parent eda7621 commit f0781fe

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

lib/codegen/meta-python/base/settings.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@
103103
"""Enable the use of atomic instructions""",
104104
default=True)
105105

106-
enable_constant_folding = BoolSetting(
107-
"""Enable the constant folding pass. This may be resource intensive""",
108-
default=False)
109-
110106
#
111107
# Settings specific to the `baldrdash` calling convention.
112108
#

lib/codegen/src/context.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ impl Context {
113113
Ok(())
114114
}
115115

116+
/// Optimize the function with available optimizations.
117+
///
118+
/// Since this can be resource intensive (and code-size inflating),
119+
/// it is separated from `Context::compile` to allow DCE to remove it
120+
/// if it's not used.
121+
pub fn optimize(&mut self, isa: &TargetIsa) -> CodegenResult<()> {
122+
self.verify_if(isa)?;
123+
self.fold_constants(isa)
124+
}
125+
116126
/// Compile the function.
117127
///
118128
/// Run the function through all the passes necessary to generate code for the target ISA
@@ -124,10 +134,6 @@ impl Context {
124134
let _tt = timing::compile();
125135
self.verify_if(isa)?;
126136

127-
if isa.flags().enable_constant_folding() {
128-
self.fold_constants(isa)?;
129-
}
130-
131137
self.compute_cfg();
132138
if isa.flags().opt_level() != OptLevel::Fastest {
133139
self.preopt(isa)?;

lib/codegen/src/settings.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ mod tests {
380380
enable_nan_canonicalization = false\n\
381381
enable_simd = true\n\
382382
enable_atomics = true\n\
383-
enable_constant_folding = false\n\
384383
baldrdash_prologue_words = 0\n\
385384
allones_funcaddrs = false\n\
386385
probestack_enabled = true\n\

0 commit comments

Comments
 (0)