Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Compiler/src/ssair/ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,10 @@ function process_node!(compact::IncrementalCompact, result_idx::Int, inst::Instr
stmt = ssa_rename[stmt.id]
end
elseif isa(stmt, NewSSAValue)
stmt = SSAValue(stmt.id)
if stmt.id > 0
# Negative ids reference new_new_nodes and must remain NewSSAValue.
stmt = SSAValue(stmt.id)
end
else
# Constant assign, replace uses of this ssa value with its result
end
Expand Down
16 changes: 16 additions & 0 deletions Compiler/test/irpasses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2134,3 +2134,19 @@ let src = code_typed1((Vector{Any},)) do xs
end
@test count(iscall((src, Core.svec)), src.code) == 1
end

# Negative NewSSAValue ids must be preserved during compaction
function f_57827(op, init, x)
v = op(init, x)
i = 0
while i < 1
v = op(v, x)
i += 1
end
return v
end
let rf = (acc, x) -> ifelse(x > acc[1], (x,), (acc[1],))
@test f_57827(rf, (0.0,), 1) === (1,)
ir = first(only(Base.code_ircode(f_57827, (typeof(rf), Tuple{Float64}, Int64); optimize_until="CC: SROA")))
@test ir isa Compiler.IRCode
end