Skip to content

Commit 3de5f61

Browse files
authored
Remove unnecessary jl_array_del_end zero-set used memset error (#1643)
1 parent f16795c commit 3de5f61

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/rules/llvmrules.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,16 +974,22 @@ function jl_array_del_end_rev(B, orig, gutils, tape)
974974
end
975975
args = LLVM.Value[anti, offset]
976976

977+
found, arty = abs_typeof(origops[1])
977978
anti = shadowin
978-
elSize = get_array_elsz(B, anti)
979-
elSize = LLVM.zext!(B, elSize, LLVM.IntType(8*sizeof(Csize_t)))
979+
elSize = if found
980+
LLVM.ConstantInt(Csize_t(sizeof(eltype(arty))))
981+
else
982+
elSize = LLVM.zext!(B, get_array_elsz(B, anti), LLVM.IntType(8*sizeof(Csize_t)))
983+
end
980984
len = get_array_len(B, anti)
981985

982986
LLVM.call!(B, fty, delF, args)
983987

984988
length = LLVM.mul!(B, len, elSize)
985989

986-
GPUCompiler.@safe_warn "TODO reverse jl_array_del_end zero-set used memset rather than runtime type of $(abs_typeof(origops[1])) in $(string(origops[1]))"
990+
if !found && !(eltype(arty) <: Base.IEEEFloat)
991+
GPUCompiler.@safe_warn "TODO reverse jl_array_del_end zero-set used memset rather than runtime type of $((found, arty)) in $(string(origops[1]))"
992+
end
987993
toset = get_array_data(B, anti)
988994
toset = gep!(B, i8, toset, LLVM.Value[length])
989995
LLVM.memset!(B, toset, LLVM.ConstantInt(i8, 0, false), elSize, algn)

0 commit comments

Comments
 (0)