Created
November 9, 2018 06:34
-
-
Save mrkn/a9eaf12809c8963ddc1777b80ed57b12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> function dot(a, b) | |
s = zero(eltype(a)) | |
for i in 1:endof(a) | |
s += a[i] * b[i] | |
end | |
return s | |
end | |
dot (generic function with 1 method) | |
julia> a = ones(100000); b = ones(100000); | |
julia> @code_llvm dot(a, b) | |
define double @julia_dot_72535(%jl_value_t*, %jl_value_t*) #0 { | |
top: | |
%2 = getelementptr inbounds %jl_value_t, %jl_value_t* %0, i64 1 | |
%3 = bitcast %jl_value_t* %2 to i64* | |
%4 = load i64, i64* %3, align 8 | |
%5 = icmp slt i64 %4, 1 | |
br i1 %5, label %L2, label %if.lr.ph | |
if.lr.ph: ; preds = %top | |
%6 = load i64, i64* %3, align 8 | |
%7 = getelementptr inbounds %jl_value_t, %jl_value_t* %1, i64 1 | |
%8 = bitcast %jl_value_t* %7 to i64* | |
%9 = bitcast %jl_value_t* %0 to double** | |
%10 = bitcast %jl_value_t* %1 to double** | |
br label %if | |
L2.loopexit: ; preds = %idxend.4 | |
br label %L2 | |
L2: ; preds = %L2.loopexit, %top | |
%s.0.lcssa = phi double [ 0.000000e+00, %top ], [ %25, %L2.loopexit ] | |
ret double %s.0.lcssa | |
if: ; preds = %if.lr.ph, %idxend.4 | |
%s.010 = phi double [ 0.000000e+00, %if.lr.ph ], [ %25, %idxend.4 ] | |
%"#temp#.09" = phi i64 [ 1, %if.lr.ph ], [ %17, %idxend.4 ] | |
%11 = add i64 %"#temp#.09", -1 | |
%12 = icmp ult i64 %11, %6 | |
br i1 %12, label %idxend, label %oob | |
oob: ; preds = %if | |
%13 = alloca i64, align 8 | |
store i64 %"#temp#.09", i64* %13, align 8 | |
call void @jl_bounds_error_ints(%jl_value_t* %0, i64* nonnull %13, i64 1) | |
unreachable | |
idxend: ; preds = %if | |
%14 = load i64, i64* %8, align 8 | |
%15 = icmp ult i64 %11, %14 | |
br i1 %15, label %idxend.4, label %oob.3 | |
oob.3: ; preds = %idxend | |
%16 = alloca i64, align 8 | |
store i64 %"#temp#.09", i64* %16, align 8 | |
call void @jl_bounds_error_ints(%jl_value_t* %1, i64* nonnull %16, i64 1) | |
unreachable | |
idxend.4: ; preds = %idxend | |
%17 = add i64 %"#temp#.09", 1 | |
%18 = load double*, double** %9, align 8 | |
%19 = getelementptr double, double* %18, i64 %11 | |
%20 = load double, double* %19, align 8 | |
%21 = load double*, double** %10, align 8 | |
%22 = getelementptr double, double* %21, i64 %11 | |
%23 = load double, double* %22, align 8 | |
%24 = fmul double %20, %23 | |
%25 = fadd double %s.010, %24 | |
%26 = icmp eq i64 %"#temp#.09", %4 | |
br i1 %26, label %L2.loopexit, label %if | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment