@@ -475,6 +475,7 @@ function add_compute!(
475475 return add_anon_func! (ls, var, fexpr, ex, position, mpref, elementbytes)
476476 # instr = instruction(first(ex.args))::Symbol
477477 instr = instruction! (ls, first (ex. args)):: Instruction
478+
478479 args = @view (ex. args[2 : end ])
479480 if (instr. instr === :pow_fast || instr. instr === :(^ )) && length (args) == 2
480481 arg1 = args[1 ]
@@ -495,6 +496,8 @@ function add_compute!(
495496 arg2num = Int (static (ex. args[3 ])):: Int
496497 return add_pow! (ls, var, args[1 ], arg2num, elementbytes, position)
497498 end
499+ elseif instr. instr === :oftype && length (args) == 2
500+ return get_arg! (ls, args[2 ], elementbytes, position)
498501 end
499502 vparents = Operation[]
500503 deps = Symbol[]
@@ -757,6 +760,34 @@ function add_compute_ifelse!(
757760 )
758761 pushop! (ls, op, LHS)
759762end
763+ function get_arg! (
764+ ls:: LoopSet ,
765+ @nospecialize (x),
766+ elementbytes:: Int ,
767+ position:: Int
768+ ):: Operation
769+ if x isa Expr
770+ add_operation! (
771+ ls,
772+ Symbol (" ###xpow###$(length (operations (ls))) ###" ),
773+ x,
774+ elementbytes,
775+ position
776+ ):: Operation
777+ elseif x isa Symbol
778+ if x ∈ ls. loopsymbols
779+ add_loopvalue! (ls, x, elementbytes)
780+ else
781+ xo = get (ls. opdict, x, nothing )
782+ xo === nothing && return add_constant! (ls, x, elementbytes):: Operation
783+ return xo
784+ end
785+ elseif x isa Number
786+ return add_constant! (ls, x^ p, elementbytes, var):: Operation
787+ else
788+ throw (" objects of type $x not supported as arg" )
789+ end
790+ end
760791
761792# adds x ^ (p::Real)
762793function add_pow! (
0 commit comments