@@ -101,18 +101,27 @@ function ensure_constant_lowered!(ls::LoopSet, mpref::ArrayReferenceMetaPosition
101
101
end
102
102
function add_constant_vload! (ls:: LoopSet , op:: Operation , mpref:: ArrayReferenceMetaPosition , elementbytes:: Int )
103
103
temp = gensym! (ls, " intermediateconstref" )
104
- vloadcall = Expr (:call , lv (:_vload ), mpref. mref. ptr)
104
+ use_getindex = vptr (name (mpref)) === mpref. mref. ptr
105
+ vloadcall = use_getindex ? Expr (:call , Base. getindex, name (mpref)) : Expr (:call , lv (:_vload ), mpref. mref. ptr)
105
106
nindices = length (getindices (op))
106
107
# getoffsets(op) .+= 1
107
108
if nindices > 0
108
109
dummyloop = first (ls. loops)
109
110
for ind ∈ getindicesonly (op)
110
111
ensure_constant_lowered! (ls, mpref, ind)
111
112
end
112
- push! (vloadcall. args, mem_offset (op, UnrollArgs (dummyloop, dummyloop, dummyloop, 0 , 0 , 0 ), fill (false ,nindices), true , ls, false ))
113
+ if use_getindex
114
+ append! (vloadcall. args, mem_offset (op, UnrollArgs (dummyloop, dummyloop, dummyloop, 0 , 0 , 0 ), fill (false ,nindices), true , ls, false ). args)
115
+ else
116
+ push! (vloadcall. args, mem_offset (op, UnrollArgs (dummyloop, dummyloop, dummyloop, 0 , 0 , 0 ), fill (false ,nindices), true , ls, false ))
117
+ end
118
+ end
119
+ if use_getindex
120
+ pushpreamble! (ls, Expr (:(= ), temp, :(@inbounds $ vloadcall)))
121
+ else
122
+ push! (vloadcall. args, Expr (:call , lv (:False )), staticexpr (reg_size (ls)))
123
+ pushpreamble! (ls, Expr (:(= ), temp, vloadcall))
113
124
end
114
- push! (vloadcall. args, Expr (:call , lv (:False )), staticexpr (reg_size (ls)))
115
- pushpreamble! (ls, Expr (:(= ), temp, vloadcall))
116
125
pushpreamble! (ls, Expr (:(= ), name (op), temp))
117
126
pushpreamble! (ls, op, temp)
118
127
return temp
0 commit comments