@@ -87,13 +87,14 @@ function transform_gpu!(def, constargs, force_inbounds, unsafe_indices)
8787 push! (let_constargs, :($ arg = $ constify ($ arg)))
8888 end
8989 end
90+ has_constargs = ! isempty (let_constargs)
9091 pushfirst! (def[:args ], :__ctx__ )
9192 new_stmts = Expr[]
9293 body = MacroTools. flatten (def[:body ])
9394 # On 1.11 and later having this aliasscope causes issues
9495 # even with kernels that don't use `@Const` on arguments
9596 # See https://github.com/JuliaGPU/KernelAbstractions.jl/issues/652
96- # push!(new_stmts, Expr(:aliasscope))
97+ has_constargs && push! (new_stmts, Expr (:aliasscope ))
9798 if ! unsafe_indices
9899 push! (new_stmts, :(__active_lane__ = $ __validindex (__ctx__)))
99100 end
@@ -108,7 +109,7 @@ function transform_gpu!(def, constargs, force_inbounds, unsafe_indices)
108109 if force_inbounds
109110 push! (new_stmts, Expr (:inbounds , :pop ))
110111 end
111- # push!(new_stmts, Expr(:popaliasscope))
112+ has_constargs && push! (new_stmts, Expr (:popaliasscope ))
112113 push! (new_stmts, :(return nothing ))
113114 def[:body ] = Expr (
114115 :let ,
@@ -132,21 +133,22 @@ function transform_cpu!(def, constargs, force_inbounds)
132133 push! (let_constargs, :($ arg = $ constify ($ arg)))
133134 end
134135 end
136+ has_constargs = ! isempty (let_constargs)
135137 pushfirst! (def[:args ], :__ctx__ )
136138 new_stmts = Expr[]
137139 body = MacroTools. flatten (def[:body ])
138140 # On 1.11 and later having this aliasscope causes issues
139141 # even with kernels that don't use `@Const` on arguments
140142 # See https://github.com/JuliaGPU/KernelAbstractions.jl/issues/652
141- # push!(new_stmts, Expr(:aliasscope))
143+ has_constargs && push! (new_stmts, Expr (:aliasscope ))
142144 if force_inbounds
143145 push! (new_stmts, Expr (:inbounds , true ))
144146 end
145147 append! (new_stmts, split (emit_cpu, body. args))
146148 if force_inbounds
147149 push! (new_stmts, Expr (:inbounds , :pop ))
148150 end
149- # push!(new_stmts, Expr(:popaliasscope))
151+ has_constargs && push! (new_stmts, Expr (:popaliasscope ))
150152 push! (new_stmts, :(return nothing ))
151153 def[:body ] = Expr (
152154 :let ,
0 commit comments