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)
857
857
args = arguments (expr)
858
858
cse_inside_expr (expr, op, args... ) || return expr
859
859
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))
861
862
if arg isa Tuple
862
863
new_arg = cse! (MakeTuple (arg), state)
863
864
sym = newsym (Tuple{symtype .(arg)... })
@@ -889,6 +890,7 @@ cse!(x::LiteralExpr, ::CSEState) = x
889
890
890
891
cse! (x:: CodegenPrimitive , state:: CSEState ) = throw (MethodError (cse!, (x, state)))
891
892
893
+ cse! (x:: AbstractRange , :: CSEState ) = x
892
894
function cse! (x:: AbstractArray , state:: CSEState )
893
895
res = map (Base. Fix2 (cse!, state), x)
894
896
return res
Original file line number Diff line number Diff line change 220
220
@test all (iszero, arr[1 : 3 ])
221
221
@test all (iszero, arr[8 : end ])
222
222
end
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