Unrolling loops over tuples - why so hard?

Since no-one has mentioned it so far, I just want to add that reduce and other folding operations unroll the implicit loop over a tuple:

julia> @code_typed reduce(+, args)
CodeInfo(
1 ─ %1  = Core.getfield(itr, 1)::UInt8
│   %2  = Core.getfield(itr, 2)::Int16
│   %3  = Core.getfield(itr, 3)::UInt32
│   %4  = Core.getfield(itr, 4)::Float32
│   %5  = Core.getfield(itr, 5)::Float64
│   %6  = Core.zext_int(Core.Int16, %1)::Int16
│   %7  = Base.add_int(%6, %2)::Int16
│   %8  = Base.sext_int(UInt32, %7)::UInt32
│   %9  = Base.add_int(%8, %3)::UInt32
│   %10 = Base.uitofp(Float32, %9)::Float32
│   %11 = Base.add_float(%10, %4)::Float32
│   %12 = Base.fpext(Base.Float64, %11)::Float64
│   %13 = Base.add_float(%12, %5)::Float64
└──       return %13
) => Float64
5 Likes