File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -857,7 +857,8 @@ function cse!(expr::Symbolic, state::CSEState)
857857 args = arguments (expr)
858858 cse_inside_expr (expr, op, args... ) || return expr
859859 args = map (args) do arg
860- if arg isa Union{Tuple, AbstractArray}
860+ if arg isa Union{Tuple, AbstractArray} &&
861+ (_is_array_of_symbolics (arg) || _is_tuple_of_symbolics (arg))
861862 if arg isa Tuple
862863 new_arg = cse! (MakeTuple (arg), state)
863864 sym = newsym (Tuple{symtype .(arg)... })
@@ -889,6 +890,7 @@ cse!(x::LiteralExpr, ::CSEState) = x
889890
890891cse! (x:: CodegenPrimitive , state:: CSEState ) = throw (MethodError (cse!, (x, state)))
891892
893+ cse! (x:: AbstractRange , :: CSEState ) = x
892894function cse! (x:: AbstractArray , state:: CSEState )
893895 res = map (Base. Fix2 (cse!, state), x)
894896 return res
Original file line number Diff line number Diff line change 220220 @test all (iszero, arr[1 : 3 ])
221221 @test all (iszero, arr[8 : end ])
222222end
223+
224+ @testset " CSE doesn't affect ranges" begin
225+ @syms x:: Array
226+ t = term (view, x, 1 : 3 )
227+ fnexpr = Func ([x], [], t)
228+ fn1 = @RuntimeGeneratedFunction (toexpr (fnexpr))
229+ fn2 = @RuntimeGeneratedFunction (cse (toexpr (fnexpr)))
230+ @test fn1 (ones (5 )) == fn2 (ones (5 ))
231+ end
You can’t perform that action at this time.
0 commit comments