Skip to content

Instantly share code, notes, and snippets.

@ArchRobison
Created January 20, 2015 22:30
Show Gist options
  • Select an option

  • Save ArchRobison/a340bc43c8fabb02e739 to your computer and use it in GitHub Desktop.

Select an option

Save ArchRobison/a340bc43c8fabb02e739 to your computer and use it in GitHub Desktop.
LLVM not doing loop-local scalar replacment
julia> ind4=CartesianIndex((1,1,1,1))
Base.IteratorsMD.CartesianIndex_4(1,1,1,1)
julia> @code_llvm(mymul(ind4,N,1))
define %CartesianIndex_4 @julia_mymul_43376(%CartesianIndex_4, i64, i64) {
top:
%3 = icmp slt i64 %1, 2, !dbg !8
br i1 %3, label %L3, label %L.preheader, !dbg !8
L.preheader: ; preds = %top
%4 = extractvalue %CartesianIndex_4 %0, 0, !dbg !9
%5 = extractvalue %CartesianIndex_4 %0, 1, !dbg !9
%6 = extractvalue %CartesianIndex_4 %0, 2, !dbg !9
%7 = extractvalue %CartesianIndex_4 %0, 3, !dbg !9
br label %L, !dbg !9
L: ; preds = %L.preheader, %L
%s.0 = phi %CartesianIndex_4 [ %19, %L ], [ %0, %L.preheader ]
%j.0 = phi i64 [ %20, %L ], [ 1, %L.preheader ]
%8 = extractvalue %CartesianIndex_4 %s.0, 0, !dbg !9
%9 = add i64 %8, %4, !dbg !9
%10 = insertvalue %CartesianIndex_4 undef, i64 %9, 0, !dbg !9
%11 = extractvalue %CartesianIndex_4 %s.0, 1, !dbg !9
%12 = add i64 %11, %5, !dbg !9
%13 = insertvalue %CartesianIndex_4 %10, i64 %12, 1, !dbg !9
%14 = extractvalue %CartesianIndex_4 %s.0, 2, !dbg !9
%15 = add i64 %14, %6, !dbg !9
%16 = insertvalue %CartesianIndex_4 %13, i64 %15, 2, !dbg !9
%17 = extractvalue %CartesianIndex_4 %s.0, 3, !dbg !9
%18 = add i64 %17, %7, !dbg !9
%19 = insertvalue %CartesianIndex_4 %16, i64 %18, 3, !dbg !9, !julia_type !10
%20 = add i64 %j.0, %2, !dbg !11
%21 = icmp slt i64 %20, %1, !dbg !11
br i1 %21, label %L, label %L3.loopexit, !dbg !11
L3.loopexit: ; preds = %L
br label %L3
L3: ; preds = %L3.loopexit, %top
%s.1 = phi %CartesianIndex_4 [ %0, %top ], [ %19, %L3.loopexit ]
ret %CartesianIndex_4 %s.1, !dbg !12
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment