Skip to content

Commit 42d40a6

Browse files
committed
Allow conditions to be symbols instead of just expressions.
1 parent 746bab0 commit 42d40a6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/add_ifelse.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ function add_if!(ls::LoopSet, LHS::Symbol, RHS::Expr, elementbytes::Int, positio
88
# for now, just simple 1-liners
99
@assert length(RHS.args) == 3 "if statements without an else cannot be assigned to a variable."
1010
condition = first(RHS.args)
11-
condop = if isnothing(mpref)
11+
condop = if condition isa Symbol
12+
getop(ls, condition, elementbytes)
13+
elseif isnothing(mpref)
1214
add_operation!(ls, gensym(:mask), condition, elementbytes, position)
1315
else
1416
add_operation!(ls, gensym(:mask), condition, mpref, elementbytes, position)

test/ifelsemasks.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ T = Float32
9999
end
100100
function addormulp1avx!(c, a, b)
101101
@avx for i eachindex(c,a,b)
102-
c[i] = 1 + (a[i] > b[i] ? a[i] + b[i] : a[i] * b[i])
102+
a_greater_than_b = a[i] > b[i]
103+
c[i] = 1 + (a_greater_than_b ? a[i] + b[i] : a[i] * b[i])
103104
end
104105
end
105106
function addifelsemul_avx!(c, a, b)

0 commit comments

Comments
 (0)