Last active
August 29, 2015 13:57
-
-
Save ArchRobison/9793916 to your computer and use it in GitHub Desktop.
Julia tuple math example without SLPVectorizer
This file contains 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
$ cat foo.jl | |
function add( a::NTuple{4,Float32}, b::NTuple{4,Float32} ) | |
(a[1]+b[1],a[2]+b[2],a[3]+b[3],a[4]+b[4]) | |
end | |
function mul( a::NTuple{4,Float32}, b::NTuple{4,Float32} ) | |
(a[1]*b[1],a[2]*b[2],a[3]*b[3],a[4]*b[4]) | |
end | |
function madd( a::NTuple{4,Float32}, b::NTuple{4,Float32}, c::NTuple{4,Float32} ) | |
add(mul(a,b),c) | |
end | |
t = NTuple{4,Float32} | |
code_llvm(madd,(t,t,t)) | |
$ julia foo.jl | |
define <4 x float> @"julia_madd;63815"(<4 x float>, <4 x float>, <4 x float>) { | |
top: | |
%3 = extractelement <4 x float> %0, i32 0, !dbg !45 | |
%4 = extractelement <4 x float> %1, i32 0, !dbg !45 | |
%5 = fmul float %3, %4, !dbg !45 | |
%6 = extractelement <4 x float> %0, i32 1, !dbg !45 | |
%7 = extractelement <4 x float> %1, i32 1, !dbg !45 | |
%8 = fmul float %6, %7, !dbg !45 | |
%9 = extractelement <4 x float> %0, i32 2, !dbg !45 | |
%10 = extractelement <4 x float> %1, i32 2, !dbg !45 | |
%11 = fmul float %9, %10, !dbg !45 | |
%12 = extractelement <4 x float> %0, i32 3, !dbg !45 | |
%13 = extractelement <4 x float> %1, i32 3, !dbg !45 | |
%14 = fmul float %12, %13, !dbg !45 | |
%15 = extractelement <4 x float> %2, i32 0, !dbg !45 | |
%16 = fadd float %5, %15, !dbg !45 | |
%17 = insertelement <4 x float> undef, float %16, i32 0, !dbg !45, !julia_type !47 | |
%18 = extractelement <4 x float> %2, i32 1, !dbg !45 | |
%19 = fadd float %8, %18, !dbg !45 | |
%20 = insertelement <4 x float> %17, float %19, i32 1, !dbg !45, !julia_type !47 | |
%21 = extractelement <4 x float> %2, i32 2, !dbg !45 | |
%22 = fadd float %11, %21, !dbg !45 | |
%23 = insertelement <4 x float> %20, float %22, i32 2, !dbg !45, !julia_type !47 | |
%24 = extractelement <4 x float> %2, i32 3, !dbg !45 | |
%25 = fadd float %14, %24, !dbg !45 | |
%26 = insertelement <4 x float> %23, float %25, i32 3, !dbg !45, !julia_type !47 | |
ret <4 x float> %26, !dbg !45 | |
} | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment