Skip to content

Commit 2776b6d

Browse files
ranochachriselrod
andauthored
fix some invalidations caused by FixedPointNumbers (#448)
* fix some invalidations caused by FixedPointNumbers * another invalidation Co-authored-by: Chris Elrod <[email protected]>
1 parent 0bf0080 commit 2776b6d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/modeling/graphs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,8 @@ function add_constant_compute!(ls::LoopSet, op::Operation, var::Symbol)::Operati
834834
if !getconstfailed
835835
f = instr.instr
836836
if f === :add_fast
837-
return add_constant!(ls, sum(vals), 8)::Operation
837+
# use init explicitly to prevent invalidations
838+
return add_constant!(ls, sum(vals; init = false), 8)::Operation
838839
elseif f === :mul_fast
839840
return add_constant!(ls, prod(vals), 8)::Operation
840841
elseif f === :sub_fast
@@ -848,7 +849,8 @@ function add_constant_compute!(ls::LoopSet, op::Operation, var::Symbol)::Operati
848849
return add_constant!(ls, vals[1] / vals[2], 8)::Operation
849850
end
850851
elseif length(opparents) == 3
851-
T = typeof(sum(vals))
852+
# use init explicitly to prevent invalidations
853+
T = typeof(sum(vals; init = false))
852854
if f === :vfmadd_fast
853855
return add_constant!(
854856
ls,

src/parse/memory_ops_common.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,8 @@ function array_reference_meta!(
859859
addconstindex!(indices, offsets, strides, loopedindex, ind)
860860
ninds += 1
861861
else
862-
vptrarray = subset_vptr!(ls, vptrarray, ninds, ind, indices, loopedindex, 0)
862+
# convert ind to reduce invalidations
863+
vptrarray = subset_vptr!(ls, vptrarray, ninds, convert(Int, ind), indices, loopedindex, 0)
863864
length(indices) == 0 && push!(indices, DISCONTIGUOUS)
864865
end
865866
elseif ind isa Expr

0 commit comments

Comments
 (0)