diff --git a/devito/passes/iet/misc.py b/devito/passes/iet/misc.py index 740fb52f23..e9d8308336 100644 --- a/devito/passes/iet/misc.py +++ b/devito/passes/iet/misc.py @@ -151,8 +151,10 @@ def _generate_macros(iet, tracker=None, **kwargs): headers = sorted((ccode(define), ccode(expr)) for define, expr in headers) # Generate Macros from higher-level SymPy objects - applications = FindApplications().visit(iet) - headers = set().union(*[_generate_macros(i) for i in applications]) + headers.extend(_generate_macros_math(iet)) + + # Remove redundancies while preserving the order + headers = filter_ordered(headers) # Some special Symbols may represent Macros defined in standard libraries, # so we need to include the respective includes