@@ -19,9 +19,12 @@ function symbolind(ind::Symbol, op::Operation, td::UnrollArgs)
19
19
Expr (:call , lv (:staticm1 ), ex)
20
20
end
21
21
22
-
22
+ staticexpr (x:: Integer ) = Expr (:call , Expr (:curly , lv (:Static ), convert (Int, x)))
23
+ staticexpr (x) = Expr (:call , lv (:Static ), x)
24
+ maybestatic (x:: Integer ) = staticexpr (x)
25
+ maybestatic (x) = x
23
26
_MMind (ind) = Expr (:call , lv (:_MM ), VECTORWIDTHSYMBOL, ind)
24
- _MMind (ind:: Integer ) = Expr (:call , lv (:_MM ), VECTORWIDTHSYMBOL, convert (Int, ind))
27
+ _MMind (ind:: Integer ) = Expr (:call , lv (:_MM ), VECTORWIDTHSYMBOL, staticexpr ( ind))
25
28
function addoffset! (ret:: Expr , ex, offset:: Integer , _mm:: Bool = false )
26
29
if iszero (offset)
27
30
if _mm
@@ -31,20 +34,15 @@ function addoffset!(ret::Expr, ex, offset::Integer, _mm::Bool = false)
31
34
return
32
35
end
33
36
elseif _mm
34
- ind = _MMind (Expr (:call , lv (:vadd ), ex, convert (Int, offset)))
37
+ ind = _MMind (Expr (:call , lv (:vadd ), ex, staticexpr ( offset)))
35
38
else
36
- ind = Expr (:call , lv (:vadd ), ex, convert (Int, offset))
39
+ ind = Expr (:call , lv (:vadd ), ex, staticexpr ( offset))
37
40
end
38
41
push! (ret. args, ind)
39
42
nothing
40
43
end
41
44
function addoffset! (ret:: Expr , offset:: Int , _mm:: Bool = false )
42
- ex = Expr (:call , Expr (:curly , lv (:Static ), offset))
43
- if _mm
44
- push! (ret. args, _MMind (ex))
45
- else
46
- push! (ret. args, ex)
47
- end
45
+ push! (ret. args, _mm ? _MMind (offset) : staticexpr (offset))
48
46
nothing
49
47
end
50
48
83
81
function add_vectorized_offset! (ret:: Expr , ind, offset, incr)
84
82
if isone (incr)
85
83
if iszero (offset)
86
- push! (ret. args, _MMind (Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, ind)))
84
+ push! (ret. args, _MMind (Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, maybestatic ( ind) )))
87
85
else
88
- push! (ret. args, _MMind (Expr (:call , lv (:vadd ), ind, Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, convert (Int, offset)))))
86
+ push! (ret. args, _MMind (Expr (:call , lv (:vadd ), ind, Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, staticexpr ( offset)))))
89
87
end
90
88
elseif iszero (incr)
91
89
if iszero (offset)
@@ -94,28 +92,28 @@ function add_vectorized_offset!(ret::Expr, ind, offset, incr)
94
92
addoffset! (ret, ind, offset, true )
95
93
end
96
94
elseif iszero (offset)
97
- push! (ret. args, _MMind (Expr (:call , lv (:valmuladd ), VECTORWIDTHSYMBOL, incr, ind)))
95
+ push! (ret. args, _MMind (Expr (:call , lv (:staticmuladd ), VECTORWIDTHSYMBOL, maybestatic ( incr), maybestatic ( ind) )))
98
96
else
99
- push! (ret. args, _MMind (Expr (:call , lv (:vadd ), ind, Expr (:call , lv (:valmuladd ), VECTORWIDTHSYMBOL, incr, convert (Int, offset)))))
97
+ push! (ret. args, _MMind (Expr (:call , lv (:vadd ), ind, Expr (:call , lv (:staticmuladd ), VECTORWIDTHSYMBOL, maybestatic ( incr), staticexpr ( offset)))))
100
98
end
101
99
end
102
100
function add_vectorized_offset_unrolled! (ret:: Expr , offset, incr)
103
101
if isone (incr)
104
102
if iszero (offset)
105
- push! (ret. args, _MMind (Expr (:call , lv (:unwrap ), VECTORWIDTHSYMBOL)))
103
+ push! (ret. args, _MMind (Expr (:call , lv (:Static ), VECTORWIDTHSYMBOL)))
106
104
else
107
- push! (ret. args, _MMind (Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, convert (Int, offset))))
105
+ push! (ret. args, _MMind (Expr (:call , lv (:valadd ), VECTORWIDTHSYMBOL, staticexpr ( offset))))
108
106
end
109
107
elseif iszero (incr)
110
108
if iszero (offset)
111
109
push! (ret. args, _MMind (Expr (:call , lv (:Zero ))))
112
110
else
113
- push! (ret. args, _MMind (convert (Int, offset)))
111
+ push! (ret. args, _MMind (staticexpr ( offset)))
114
112
end
115
113
elseif iszero (offset)
116
- push! (ret. args, _MMind (Expr (:call , lv (:valmul ), VECTORWIDTHSYMBOL, incr)))
114
+ push! (ret. args, _MMind (Expr (:call , lv (:staticmul ), VECTORWIDTHSYMBOL, maybestatic ( incr) )))
117
115
else
118
- push! (ret. args, _MMind (Expr (:call , lv (:valmuladd ), VECTORWIDTHSYMBOL, incr, convert (Int, offset))))
116
+ push! (ret. args, _MMind (Expr (:call , lv (:staticmuladd ), VECTORWIDTHSYMBOL, maybestatic ( incr), staticexpr ( offset))))
119
117
end
120
118
end
121
119
function add_vectorized_offset! (ret:: Expr , ind, offset, incr, unrolled)
0 commit comments