Skip to content

Commit

Permalink
Some test move.
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed May 11, 2022
1 parent d03e7e2 commit 8a02e52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
27 changes: 26 additions & 1 deletion test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1571,8 +1571,15 @@ end
@test reshape(r, :) === reshape(r, (:,)) === r
end

module IRUtils
include(normpath(@__DIR__, "./compiler/irutils.jl"))
end

@testset "strides for ReshapedArray" begin
# Type-based contiguous check is tested in test/compiler/inline.jl
# Type-based contiguous Check
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
f(a) = only(strides(a));
@test IRUtils.fully_eliminated(f, Base.typesof(a)) && f(a) == 1
# General contiguous check
a = view(rand(10,10), 1:10, 1:10)
@test strides(vec(a)) == (1,)
Expand Down Expand Up @@ -1610,3 +1617,21 @@ end
i = CartesianIndex((1,1))
@test (@inferred A[i,i,i]) === A[1]
end

@testset "type-based offset axes check" begin
a = randn(ComplexF64, 10)
ta = reinterpret(Float64, a)
tb = reinterpret(Float64, view(a, 1:2:10))
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
# Issue #44040
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
# Ranges && CartesianIndices
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(1:10,Base.OneTo(10),1.0:2.0,LinRange(1.0,2.0,2),1:2:10,CartesianIndices((1:2:10,1:2:10))))
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
a, b = zeros(2,2,2), zeros(2,2)
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
end
25 changes: 0 additions & 25 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -995,13 +995,6 @@ end
Base.@invoke conditional_escape!(false::Any, x::Any)
end

@testset "strides for ReshapedArray (PR#44027)" begin
# Type-based contiguous check
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
f(a) = only(strides(a));
@test fully_eliminated(f, Tuple{typeof(a)}) && f(a) == 1
end

@testset "elimination of `get_binding_type`" begin
m = Module()
@eval m begin
Expand Down Expand Up @@ -1259,21 +1252,3 @@ end
@test fully_eliminated() do
return maybe_error_int(1)
end

@testset "type-based offset axes check" begin
a = randn(ComplexF64, 10)
ta = reinterpret(Float64, a)
tb = reinterpret(Float64, view(a, 1:2:10))
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
# Issue #44040
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
# Ranges && CartesianIndices
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(1:10,Base.OneTo(10),1.0:2.0,LinRange(1.0,2.0,2),1:2:10,CartesianIndices((1:2:10,1:2:10))))
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
a, b = zeros(2,2,2), zeros(2,2)
@test_broken fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
end

0 comments on commit 8a02e52

Please sign in to comment.