Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline: Skip explicit intrinsics when inlining stmt functions #461

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion loki/transformations/inline/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ 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 is None or expr.procedure_type is BasicType.DEFERRED \
or expr.procedure_type.is_intrinsic:
mlange05 marked this conversation as resolved.
Show resolved Hide resolved
# 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
Loading