Skip to content

Commit

Permalink
Merge pull request #461 from ecmwf-ifs/naml-fix-stmt-func-inlining-wi…
Browse files Browse the repository at this point in the history
…th-intrinsics

Inline: Skip explicit intrinsics when inlining stmt functions
  • Loading branch information
reuterbal authored Dec 18, 2024
2 parents 1e4d3e4 + 53394c7 commit ad1e2bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion loki/transformations/inline/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def map_procedure_symbol(self, expr, *args, **kwargs):
return expr.clone(parent=parent)

def map_inline_call(self, expr, *args, **kwargs):
if expr.procedure_type is None or expr.procedure_type is BasicType.DEFERRED:
if expr.procedure_type in (None, BasicType.DEFERRED) or expr.procedure_type.is_intrinsic:
# Unkonw inline call, potentially an intrinsic
# We still need to recurse and ensure re-scoping
return super().map_inline_call(expr, *args, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions loki/transformations/inline/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_inline_statement_functions(frontend, stmt_decls):
real :: FOEDELTA
FOEDELTA ( PTARE ) = PTARE + 1.0
real :: FOEEW
FOEEW ( PTARE ) = PTARE + FOEDELTA(PTARE)
FOEEW ( PTARE ) = PTARE + FOEDELTA(PTARE) + EXP(PTARE)
""".strip()

fcode = f"""
Expand All @@ -280,10 +280,10 @@ def test_inline_statement_functions(frontend, stmt_decls):

assert not FindNodes(ir.StatementFunction).visit(routine.spec)
if stmt_decls:
assert not FindInlineCalls().visit(routine.body)
assert len(FindInlineCalls().visit(routine.body)) == 1
assignments = FindNodes(ir.Assignment).visit(routine.body)
assert assignments[0].lhs == 'ret'
assert assignments[0].rhs == "arr + arr + 1.0"
assert assignments[0].rhs == "arr + arr + 1.0 + exp(arr)"
assert assignments[1].lhs == 'ret2'
assert assignments[1].rhs == "3.0 + 1.0"
else:
Expand Down

0 comments on commit ad1e2bc

Please sign in to comment.