GNU Octave, version 3.7.0+ Copyright (C) 2012 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. Octave was configured for "i686-pc-mingw32". Additional information about Octave is available at http://www.octave.org. Please contribute if you find this software useful. For more information, visit http://www.octave.org/help-wanted.html Read http://www.octave.org/bugs.html to learn how to submit bug reports. For information about changes from previous versions, type `news'. inc = 1.0000e-005 result = 0 -------------------- Compiling tree -------------------- for ii = 0:inc:1 result = result + inc * (1 / 3 * ii ^ 2); endfor -------------------- octave jit ir -------------------- body0: %pred = scalar: inc#9 = extract inc scalar: result#8 = extract result any: ii#6 = extract ii range: #for_bounds0#0 = extract #for_bounds0 index: #1 = call for_init (range: #for_bounds0#0) index: #iter0#2 = index: #1 bool: #3 = call for_check (range: #for_bounds0#0, index: #iter0#2) cond_branch: bool: #3, [live] phi_split2, [live] phi_split1 phi_split2: %pred = body0 call release (any: ii#6) complex: #49 = call (complex) (scalar: result#8) complex: result#50 = complex: #49 branch: [live] for_body4 for_body4: %pred = phi_split2, phi_split3 complex: result#36 phi | phi_split2 -> complex: result#50 | phi_split3 -> complex: result#18 scalar: inc#34 phi | phi_split2 -> scalar: inc#9 | phi_split3 -> scalar: inc#34 index: #iter0#30 phi | phi_split2 -> index: #iter0#2 | phi_split3 -> index: #iter0#21 range: #for_bounds0#28 phi | phi_split2 -> range: #for_bounds0#0 | phi_split3 -> range: #for_bounds0#28 scalar: #5 = call for_index (range: #for_bounds0#28, index: #iter0#30) scalar: ii#7 = scalar: #5 complex: #10 = call binary^ (scalar: ii#7, scalar: 2) complex: #12 = call binary* (scalar: 0.333333, complex: #10) call release (complex: #10) branch: [live] for_body5 for_body5: %pred = for_body4 complex: #14 = call binary* (scalar: inc#34, complex: #12) call release (complex: #12) complex: #16 = call binary+ (complex: result#36, complex: #14) call release (complex: #14) branch: [live] for_body6 for_body6: %pred = for_body5 complex: result#18 = complex: #16 index: #20 = call binary+ (index: #iter0#30, index: 1) index: #iter0#21 = index: #20 bool: #22 = call for_check (range: #for_bounds0#28, index: #iter0#21) cond_branch: bool: #22, [live] phi_split3, [live] phi_split7 phi_split3: %pred = for_body6 call release (scalar: ii#7) branch: [live] for_body4 phi_split1: %pred = body0 complex: #52 = call (complex) (scalar: result#8) complex: result#53 = complex: #52 branch: [live] for_tail8 phi_split7: %pred = for_body6 any: #55 = call (range) (scalar: ii#7) any: ii#56 = any: #55 branch: [live] for_tail8 for_tail8: %pred = phi_split1, phi_split7 complex: result#37 phi | phi_split1 -> complex: result#53 | phi_split7 -> complex: result#18 scalar: inc#35 phi | phi_split1 -> scalar: inc#9 | phi_split7 -> scalar: inc#34 any: ii#33 phi | phi_split1 -> any: ii#6 | phi_split7 -> any: ii#56 index: #iter0#31 phi | phi_split1 -> index: #iter0#2 | phi_split7 -> index: #iter0#21 range: #for_bounds0#29 phi | phi_split1 -> range: #for_bounds0#0 | phi_split7 -> range: #for_bounds0#28 store ii = any: ii#33 store inc = scalar: inc#35 store result = complex: result#37 -------------------- llvm ir -------------------- define void @foobar(%octave_base_value**) { prelude: %1 = getelementptr inbounds %octave_base_value** %0, i32 0 %2 = getelementptr inbounds %octave_base_value** %0, i32 1 %3 = getelementptr inbounds %octave_base_value** %0, i32 2 %4 = getelementptr inbounds %octave_base_value** %0, i32 3 br label %body body: ; preds = %prelude %5 = load %octave_base_value** %1 %6 = call double @octave_jit_cast_scalar_any(%octave_base_value* %5) %7 = load %octave_base_value** %2 %8 = call double @octave_jit_cast_scalar_any(%octave_base_value* %7) %9 = load %octave_base_value** %3 %10 = call %octave_base_value* @id4(%octave_base_value* %9) %11 = load %octave_base_value** %4 %12 = call i8* @llvm.stacksave() %13 = alloca %range call void @octave_jit_cast_range_any(%range* %13, %octave_base_value* %11) %14 = load %range* %13 call void @llvm.stackrestore(i8* %12) %15 = call i32 @octave_jit_for_range_init(%range %14) %16 = call i1 @octave_jit_for_range_check(%range %14, i32 %15) br i1 %16, label %phi_split, label %phi_split4 phi_split: ; preds = %body call void @octave_jit_release_any(%octave_base_value* %10) %17 = call <2 x double> @octave_jit_cast_complex_scalar(double %8) br label %for_body for_body: ; preds = %phi_split3, %phi_split %18 = phi <2 x double> [ %17, %phi_split ], [ %34, %phi_split3 ] %19 = phi double [ %6, %phi_split ], [ %19, %phi_split3 ] %20 = phi i32 [ %15, %phi_split ], [ %37, %phi_split3 ] %21 = phi %range [ %14, %phi_split ], [ %21, %phi_split3 ] %22 = call double @octave_jit_for_range_idx(%range %21, i32 %20) %23 = call i8* @llvm.stacksave() %24 = alloca %complex_ret call void @octave_jit_pow_scalar_scalar(%complex_ret* %24, double %22, double 2.000000e+00) %25 = load %complex_ret* %24 %26 = extractvalue %complex_ret %25, 0 %27 = extractvalue %complex_ret %25, 1 %28 = insertelement <2 x double> undef, double %26, i32 0 %29 = insertelement <2 x double> %28, double %27, i32 1 call void @llvm.stackrestore(i8* %23) %30 = call <2 x double> @"octave_jit_*_scalar_complex"(double 0x3FD5555555555555, <2 x double> %29) %31 = call <2 x double> @id1(<2 x double> %29) br label %for_body1 for_body1: ; preds = %for_body %32 = call <2 x double> @"octave_jit_*_scalar_complex"(double %19, <2 x double> %30) %33 = call <2 x double> @id1(<2 x double> %30) %34 = call <2 x double> @"octave_jit_+_complex"(<2 x double> %18, <2 x double> %32) %35 = call <2 x double> @id1(<2 x double> %32) br label %for_body2 for_body2: ; preds = %for_body1 %36 = call <2 x double> @id1(<2 x double> %18) %37 = call i32 @"octave_jit_+_index"(i32 %20, i32 1) %38 = call i32 @id2(i32 %20) %39 = call i1 @octave_jit_for_range_check(%range %21, i32 %37) br i1 %39, label %phi_split3, label %phi_split5 phi_split3: ; preds = %for_body2 %40 = call double @id(double %22) br label %for_body phi_split4: ; preds = %body %41 = call <2 x double> @octave_jit_cast_complex_scalar(double %8) br label %for_tail phi_split5: ; preds = %for_body2 %42 = call %octave_base_value* @octave_jit_cast_any_scalar(double %22) br label %for_tail for_tail: ; preds = %phi_split5, %phi_split4 %43 = phi <2 x double> [ %41, %phi_split4 ], [ %34, %phi_split5 ] %44 = phi double [ %6, %phi_split4 ], [ %19, %phi_split5 ] %45 = phi %octave_base_value* [ %10, %phi_split4 ], [ %42, %phi_split5 ] %46 = phi i32 [ %15, %phi_split4 ], [ %37, %phi_split5 ] %47 = phi %range [ %14, %phi_split4 ], [ %21, %phi_split5 ] %48 = call %octave_base_value* @id4(%octave_base_value* %45) store %octave_base_value* %48, %octave_base_value** %3 %49 = call %octave_base_value* @octave_jit_cast_any_scalar(double %44) store %octave_base_value* %49, %octave_base_value** %1 %50 = extractelement <2 x double> %43, i32 0 %51 = extractelement <2 x double> %43, i32 1 %52 = insertvalue %complex_ret undef, double %50, 0 %53 = insertvalue %complex_ret %52, double %51, 1 %54 = call %octave_base_value* @octave_jit_cast_any_complex(%complex_ret %53) store %octave_base_value* %54, %octave_base_value** %2 ret void } -------------------- optimized llvm ir -------------------- define void @foobar(%octave_base_value**) { prelude: %1 = getelementptr inbounds %octave_base_value** %0, i32 1 %2 = getelementptr inbounds %octave_base_value** %0, i32 2 %3 = getelementptr inbounds %octave_base_value** %0, i32 3 %4 = load %octave_base_value** %0, align 4 %5 = call double @octave_jit_cast_scalar_any(%octave_base_value* %4) %6 = load %octave_base_value** %1, align 4 %7 = call double @octave_jit_cast_scalar_any(%octave_base_value* %6) %8 = load %octave_base_value** %2, align 4 %9 = load %octave_base_value** %3, align 4 %10 = call i8* @llvm.stacksave() %11 = alloca %range, align 8 call void @octave_jit_cast_range_any(%range* %11, %octave_base_value* %9) %12 = load %range* %11, align 8 call void @llvm.stackrestore(i8* %10) %13 = extractvalue %range %12, 3 %14 = icmp eq i32 %13, 0 br i1 %14, label %phi_split4, label %phi_split phi_split: ; preds = %prelude call void @octave_jit_release_any(%octave_base_value* %8) %15 = insertelement <2 x double> undef, double %7, i32 0 %16 = insertelement <2 x double> %15, double 0.000000e+00, i32 1 br label %for_body for_body: ; preds = %for_body, %phi_split %17 = phi <2 x double> [ %16, %phi_split ], [ %35, %for_body ] %18 = phi i32 [ 0, %phi_split ], [ %36, %for_body ] %19 = sitofp i32 %18 to double %20 = extractvalue %range %12, 0 %21 = extractvalue %range %12, 2 %22 = fmul double %19, %21 %23 = fadd double %20, %22 %24 = call i8* @llvm.stacksave() %25 = alloca %complex_ret, align 8 call void @octave_jit_pow_scalar_scalar(%complex_ret* %25, double %23, double 2.000000e+00) %26 = load %complex_ret* %25, align 8 call void @llvm.stackrestore(i8* %24) %27 = extractvalue %complex_ret %26, 0 %28 = insertelement <2 x double> undef, double %27, i32 0 %29 = extractvalue %complex_ret %26, 1 %30 = insertelement <2 x double> %28, double %29, i32 1 %31 = fmul <2 x double> %30, %32 = insertelement <2 x double> undef, double %5, i32 0 %33 = insertelement <2 x double> %32, double %5, i32 1 %34 = fmul <2 x double> %33, %31 %35 = fadd <2 x double> %17, %34 %36 = add i32 %18, 1 %37 = icmp ult i32 %36, %13 br i1 %37, label %for_body, label %phi_split5 phi_split4: ; preds = %prelude %38 = insertelement <2 x double> undef, double %7, i32 0 %39 = insertelement <2 x double> %38, double 0.000000e+00, i32 1 br label %for_tail phi_split5: ; preds = %for_body %40 = call %octave_base_value* @octave_jit_cast_any_scalar(double %23) br label %for_tail for_tail: ; preds = %phi_split5, %phi_split4 %41 = phi <2 x double> [ %39, %phi_split4 ], [ %35, %phi_split5 ] %42 = phi %octave_base_value* [ %8, %phi_split4 ], [ %40, %phi_split5 ] store %octave_base_value* %42, %octave_base_value** %2, align 4 %43 = call %octave_base_value* @octave_jit_cast_any_scalar(double %5) store %octave_base_value* %43, %octave_base_value** %0, align 4 %44 = extractelement <2 x double> %41, i32 0 %45 = extractelement <2 x double> %41, i32 1 %46 = insertvalue %complex_ret undef, double %44, 0 %47 = insertvalue %complex_ret %46, double %45, 1 %48 = call %octave_base_value* @octave_jit_cast_any_complex(%complex_ret %47) store %octave_base_value* %48, %octave_base_value** %1, align 4 ret void }