Skip to content
Snippets Groups Projects
Commit ce3fb3e8 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

add another late constant folding pass

parent a04c241b
No related branches found
No related tags found
1 merge request!421Refactor Field Modelling
Pipeline #69785 passed
...@@ -132,7 +132,7 @@ def create_kernel( ...@@ -132,7 +132,7 @@ def create_kernel(
f"Code generation for target {target} not implemented" f"Code generation for target {target} not implemented"
) )
# Simplifying transformations # Fold and extract constants
elim_constants = EliminateConstants(ctx, extract_constant_exprs=True) elim_constants = EliminateConstants(ctx, extract_constant_exprs=True)
kernel_ast = cast(PsBlock, elim_constants(kernel_ast)) kernel_ast = cast(PsBlock, elim_constants(kernel_ast))
...@@ -151,10 +151,16 @@ def create_kernel( ...@@ -151,10 +151,16 @@ def create_kernel(
select_functions = SelectFunctions(platform) select_functions = SelectFunctions(platform)
kernel_ast = cast(PsBlock, select_functions(kernel_ast)) kernel_ast = cast(PsBlock, select_functions(kernel_ast))
# Lowering introduces new symbols, which have to be canonicalized # Late canonicalization and constant elimination passes
# * Since lowering introduces new index calculations and indexing symbols into the AST,
# * these need to be handled here
canonicalize = CanonicalizeSymbols(ctx, True) canonicalize = CanonicalizeSymbols(ctx, True)
kernel_ast = cast(PsBlock, canonicalize(kernel_ast)) kernel_ast = cast(PsBlock, canonicalize(kernel_ast))
late_fold_constants = EliminateConstants(ctx, extract_constant_exprs=False)
kernel_ast = cast(PsBlock, late_fold_constants(kernel_ast))
if config.target.is_cpu(): if config.target.is_cpu():
return create_cpu_kernel_function( return create_cpu_kernel_function(
ctx, ctx,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment