Skip to content

Commit 9d37b62

Browse files
committed
Some test move.
1 parent 8dd18c3 commit 9d37b62

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

test/abstractarray.jl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,15 @@ end
15711571
@test reshape(r, :) === reshape(r, (:,)) === r
15721572
end
15731573

1574+
module IRUtils
1575+
include(normpath(@__DIR__, "./compiler/irutils.jl"))
1576+
end
1577+
15741578
@testset "strides for ReshapedArray" begin
1575-
# Type-based contiguous check is tested in test/compiler/inline.jl
1579+
# Type-based contiguous Check
1580+
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
1581+
f(a) = only(strides(a));
1582+
@test IRUtils.fully_eliminated(f, Base.typesof(a)) && f(a) == 1
15761583
# General contiguous check
15771584
a = view(rand(10,10), 1:10, 1:10)
15781585
@test strides(vec(a)) == (1,)
@@ -1610,3 +1617,21 @@ end
16101617
i = CartesianIndex((1,1))
16111618
@test (@inferred A[i,i,i]) === A[1]
16121619
end
1620+
1621+
@testset "type-based offset axes check" begin
1622+
a = randn(ComplexF64, 10)
1623+
ta = reinterpret(Float64, a)
1624+
tb = reinterpret(Float64, view(a, 1:2:10))
1625+
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
1626+
# Issue #44040
1627+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
1628+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
1629+
@test IRUtils.fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
1630+
# Ranges && CartesianIndices
1631+
@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))))
1632+
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
1633+
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
1634+
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
1635+
a, b = zeros(2,2,2), zeros(2,2)
1636+
@test_broken IRUtils.fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
1637+
end

test/compiler/inline.jl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -995,13 +995,6 @@ end
995995
Base.@invoke conditional_escape!(false::Any, x::Any)
996996
end
997997

998-
@testset "strides for ReshapedArray (PR#44027)" begin
999-
# Type-based contiguous check
1000-
a = vec(reinterpret(reshape,Int16,reshape(view(reinterpret(Int32,randn(10)),2:11),5,:)))
1001-
f(a) = only(strides(a));
1002-
@test fully_eliminated(f, Tuple{typeof(a)}) && f(a) == 1
1003-
end
1004-
1005998
@testset "elimination of `get_binding_type`" begin
1006999
m = Module()
10071000
@eval m begin
@@ -1259,21 +1252,3 @@ end
12591252
@test fully_eliminated() do
12601253
return maybe_error_int(1)
12611254
end
1262-
1263-
@testset "type-based offset axes check" begin
1264-
a = randn(ComplexF64, 10)
1265-
ta = reinterpret(Float64, a)
1266-
tb = reinterpret(Float64, view(a, 1:2:10))
1267-
tc = reinterpret(Float64, reshape(view(a, 1:3:10), 2, 2, 1))
1268-
# Issue #44040
1269-
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc))
1270-
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(tc,tc))
1271-
@test fully_eliminated(Base.require_one_based_indexing, Base.typesof(ta,tc,tb))
1272-
# Ranges && CartesianIndices
1273-
@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))))
1274-
# Remind us to call `any` in `Base.has_offset_axes` once our compiler is ready.
1275-
@inline _has_offset_axes(A) = @inline any(x->Int(first(x))::Int != 1, axes(A))
1276-
@inline _has_offset_axes(As...) = @inline any(_has_offset_axes, As)
1277-
a, b = zeros(2,2,2), zeros(2,2)
1278-
@test_broken fully_eliminated(_has_offset_axes, Base.typesof(a,a,b,b))
1279-
end

0 commit comments

Comments
 (0)