sorry for the noise, but explaining it to someone else made me realise i 
still didn't have it right.  below it the expanded typed. native and llvm 
code.  above are wrong.  this is for the 10 -1 1 loop.

it's pretty clean - no unboxing in the native code (at least, no QWORDs 
which i think is that).

code at https://github.com/andrewcooke/IntModN.jl/blob/master/src/Range.jl

$(Expr(:lambda, {:r}, 
{{:n,:#s7,:#s6,:i,:_var0,:_var1},{{:r,TypedRange{10,-1,1},0},{:n,Int64,2},{:#s7,Int64,2},{:#s6,(Int64,Int64),18},{:i,Int64,18},{:_var0,Int64,18},{:_var1,Int64,18}},{}},
 
:(begin  # /home/andrew/.julia/v0.3/IntModN/src/Range.jl, line 44:
        n = 0 # line 45:
        #s7 = top(box)(Int64,top(sub_int)(10,-1))::Int64
        unless 
top(box)(Bool,top(not_int)(top(done)(r::TypedRange{10,-1,1},#s7::Int64)::Bool))::Bool
 
goto 1
        2: 
        _var0 = top(box)(Int64,top(add_int)(#s7::Int64,-1))::Int64
        _var1 = top(box)(Int64,top(add_int)(#s7::Int64,-1))::Int64
        i = _var0::Int64
        #s7 = _var1::Int64 # line 46:
        n = top(box)(Int64,top(add_int)(n::Int64,i::Int64))::Int64
        3: 
        unless top(box)(Bool,top(not_int)(top(box)(Bool,top(not_int)(top(
done)(r::TypedRange{10,-1,1},#s7::Int64)::Bool))::Bool))::Bool goto 2
        1: 
        0:  # line 48:
        return n::Int64
    end::Int64)))

        .text
Filename: /home/andrew/.julia/v0.3/IntModN/src/Range.jl
Source line: 45
        push    RBP
        mov     RBP, RSP
        push    R15
        push    R14
        push    R12
        push    RBX
        mov     R14, RDI
Source line: 45
        movabs  R12, 140099758330272
        mov     ESI, 11
        call    R12
        xor     R15D, R15D
        test    AL, 1
        jne     29
        mov     EBX, 10
Source line: 46
        mov     RDI, R14
        mov     RSI, RBX
        call    R12
        add     R15, RBX
        dec     RBX
        test    AL, 1
        je      -24
Source line: 48
        mov     RAX, R15
        pop     RBX
        pop     R12
        pop     R14
        pop     R15
        pop     RBP
        ret

define i64 @julia_count_type15529(%jl_value_t*) {
top:
  %1 = call i1 @julia_done15439(%jl_value_t* %0, i64 11), !dbg !430
  br i1 %1, label %L3, label %L, !dbg !430

L:                                                ; preds = %top, %L
  %"#s7.0" = phi i64 [ %2, %L ], [ 11, %top ]
  %n.0 = phi i64 [ %3, %L ], [ 0, %top ]
  %2 = add i64 %"#s7.0", -1, !dbg !430
  %3 = add i64 %2, %n.0, !dbg !431
  %4 = call i1 @julia_done15439(%jl_value_t* %0, i64 %2), !dbg !431
  br i1 %4, label %L3, label %L, !dbg !431

L3:                                               ; preds = %L, %top
  %n.1 = phi i64 [ 0, %top ], [ %3, %L ]
  ret i64 %n.1, !dbg !432
}



Reply via email to