@@ -18,10 +18,15 @@ Base.iterate(p::Core.Compiler.Pair, st) = Core.Compiler.iterate(p, st)
1818
1919Base. getindex (m:: Core.Compiler.MethodLookupResult , idx:: Int ) = Core. Compiler. getindex (m, idx)
2020
21- function Core. Compiler. optimize (interp:: YaoInterpreter , opt:: OptimizationState , params:: OptimizationParams , @nospecialize (result))
21+ function Core. Compiler. optimize (
22+ interp:: YaoInterpreter ,
23+ opt:: OptimizationState ,
24+ params:: OptimizationParams ,
25+ @nospecialize (result)
26+ )
2227 nargs = Int (opt. nargs) - 1
2328 @timeit " optimizer" ir = Core. Compiler. run_passes (opt. src, nargs, opt)
24-
29+
2530 # make sure all const are inlined
2631 # Julia itself may not inline all
2732 # the const values we want, e.g gates
@@ -204,31 +209,31 @@ function inline_const!(ir::IRCode)
204209 break
205210 end
206211 end
207-
212+
208213 if allconst &&
209214 isa (f, Core. IntrinsicFunction) &&
210215 is_pure_intrinsic_infer (f) &&
211216 intrinsic_nothrow (f, atypes[2 : end ])
212-
217+
213218 fargs = anymap (x:: Const -> x. val, atypes[2 : end ])
214219 val = f (fargs... )
215220 ir. stmts[i][:inst ] = quoted (val)
216221 ir. stmts[i][:type ] = Const (val)
217- elseif allconst && isa (f, Core. Builtin) &&
218- (f === Core. tuple || f === Core. getfield)
222+ elseif allconst && isa (f, Core. Builtin) && (f === Core. tuple || f === Core. getfield)
219223 fargs = anymap (x:: Const -> x. val, atypes[2 : end ])
220224 val = f (fargs... )
221225 ir. stmts[i][:inst ] = quoted (val)
222226 ir. stmts[i][:type ] = Const (val)
223227 end
224228 elseif stmt. head === :new
225229 exargs = stmt. args[2 : end ]
226- allconst = all (arg-> is_arg_allconst (ir, arg), exargs)
230+ allconst = all (arg -> is_arg_allconst (ir, arg), exargs)
227231 t = stmt. args[1 ]
228232 if allconst && isconcretetype (t) && ! t. mutable
229- args = anymap (arg-> unwrap_arg (ir, arg), exargs)
230- val = ccall (:jl_new_structv , Any, (Any, Ptr{Cvoid}, UInt32), t, args, length (args))
231-
233+ args = anymap (arg -> unwrap_arg (ir, arg), exargs)
234+ val =
235+ ccall (:jl_new_structv , Any, (Any, Ptr{Cvoid}, UInt32), t, args, length (args))
236+
232237 ir. stmts[i][:inst ] = quoted (val)
233238 ir. stmts[i][:type ] = Const (val)
234239 end
@@ -245,11 +250,11 @@ function elim_map_check!(ir::IRCode)
245250
246251 if stmt. head === :invoke && stmt. args[2 ] === GlobalRef (YaoLocations, :map_check )
247252 exargs = stmt. args[3 : end ]
248- allconst = all (arg-> is_arg_allconst (ir, arg), exargs)
253+ allconst = all (arg -> is_arg_allconst (ir, arg), exargs)
249254
250255
251256 if allconst
252- args = anymap (arg-> unwrap_arg (ir, arg), exargs)
257+ args = anymap (arg -> unwrap_arg (ir, arg), exargs)
253258 val = map_check_nothrow (args[1 ], args[2 ])
254259
255260 ir. stmts[i][:inst ] = quoted (val)
0 commit comments