Skip to content

Commit 671bbdd

Browse files
committed
fixes 28
1 parent ce797c6 commit 671bbdd

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/add_compute.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function add_reduction_update_parent!(
7272
if !isloopconstant
7373
# and parent is not a reduction_zero
7474
reduct_zero = REDUCTION_ZERO[Instr]
75-
reductcombine = REDUCTION_SCALAR_COMBINE[Instr].name
75+
reductcombine::Symbol = @static VERSION < v"1.3" ? last(REDUCTION_SCALAR_COMBINE[Instr].args).value : REDUCTION_SCALAR_COMBINE[Instr].name
7676
reductsym = gensym(:reduction)
7777
reductinit = add_constant!(ls, Expr(:call, reduct_zero, ls.T), loopdependencies(parent), reductsym, reduct_zero, elementbytes)
7878
if isconstant(parent) && reduct_zero === parent.instruction.mod #we can use parent op as initialization.

src/costs.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
@static if VERSION < v"1.3"
3+
lv(x) = Expr(:(.), :LoopVectorization, QuoteNode(x))
4+
else
5+
lv(x) = GlobalRef(LoopVectorization, x)
6+
end
7+
8+
9+
210
struct Instruction
311
mod::Symbol
412
instr::Symbol
@@ -222,9 +230,9 @@ const REDUCTION_ZERO = Dict{Instruction,Symbol}(
222230
Instruction(:vfnmsub_fast) => :zero
223231
)
224232

225-
lv(x) = GlobalRef(LoopVectorization, x)
233+
const LVGETPROP = @static VERSION < v"1.3" ? Expr : GlobalRef
226234
# Fast functions, because common pattern is
227-
const REDUCTION_SCALAR_COMBINE = Dict{Instruction,GlobalRef}(
235+
const REDUCTION_SCALAR_COMBINE = Dict{Instruction,LVGETPROP}(
228236
Instruction(:+) => lv(:reduced_add),
229237
Instruction(:vadd) => lv(:reduced_add),
230238
Instruction(:*) => lv(:reduced_prod),

src/lowering.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function reduce_range!(q::Expr, toreduct::Symbol, instr::Instruction, Uh::Int, U
199199
push!(q.args, Expr(:(=), tru, Expr(instr, tru, Symbol(toreduct, u + Uh))))
200200
end
201201
for u 2Uh:Uh2-1
202-
tru = Symbol(toreduct, u + 1 - 2Uh)
202+
tru = Symbol(toreduct, u - 2Uh)
203203
push!(q.args, Expr(:(=), tru, Expr(instr, tru, Symbol(toreduct, u))))
204204
end
205205
end

0 commit comments

Comments
 (0)