Last active
October 22, 2016 18:15
-
-
Save bluss/4409af8b7765307e46504e1a3af350a3 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
; ModuleID = 'chain_bool_split.cgu-0.rs' | |
source_filename = "chain_bool_split.cgu-0.rs" | |
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-unknown-linux-gnu" | |
%"2.std::ops::Range<usize>" = type { i64, i64 } | |
%"8.unwind::libunwind::_Unwind_Exception" = type { i64, void (i32, %"8.unwind::libunwind::_Unwind_Exception"*)*, [6 x i64] } | |
%"8.unwind::libunwind::_Unwind_Context" = type {} | |
; Function Attrs: uwtable | |
define i64 @range_chain_default_fold(%"2.std::ops::Range<usize>"* noalias nocapture readonly dereferenceable(16), %"2.std::ops::Range<usize>"* noalias nocapture readonly dereferenceable(16), i64 (i64, i64)* nocapture) unnamed_addr #0 personality i32 (i32, i32, i64, %"8.unwind::libunwind::_Unwind_Exception"*, %"8.unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality { | |
entry-block: | |
%3 = getelementptr inbounds %"2.std::ops::Range<usize>", %"2.std::ops::Range<usize>"* %0, i64 0, i32 0 | |
%4 = getelementptr inbounds %"2.std::ops::Range<usize>", %"2.std::ops::Range<usize>"* %0, i64 0, i32 1 | |
%5 = load i64, i64* %3, align 8 | |
%6 = load i64, i64* %4, align 8 | |
%7 = getelementptr inbounds %"2.std::ops::Range<usize>", %"2.std::ops::Range<usize>"* %1, i64 0, i32 0 | |
%8 = getelementptr inbounds %"2.std::ops::Range<usize>", %"2.std::ops::Range<usize>"* %1, i64 0, i32 1 | |
%9 = load i64, i64* %7, align 8 | |
%10 = load i64, i64* %8, align 8 | |
%11 = icmp ult i64 %5, %6 | |
br i1 %11, label %bb6.preheader, label %bb1.outer28.preheader | |
bb6.preheader: ; preds = %entry-block | |
br label %bb6 | |
bb1.outer28.preheader.loopexit: ; preds = %bb6 | |
br label %bb1.outer28.preheader | |
bb1.outer28.preheader: ; preds = %bb1.outer28.preheader.loopexit, %entry-block | |
%accum.0.ph32.ph = phi i64 [ 0, %entry-block ], [ %15, %bb1.outer28.preheader.loopexit ] | |
br label %bb1.outer28 | |
bb1.outer28: ; preds = %bb1.outer28.preheader, %bb10 | |
%b.sroa.0.0.ph29 = phi i64 [ %17, %bb10 ], [ %9, %bb1.outer28.preheader ] | |
%accum.0.ph32 = phi i64 [ %18, %bb10 ], [ %accum.0.ph32.ph, %bb1.outer28.preheader ] | |
%front_active.0.ph33 = phi i8 [ 0, %bb10 ], [ 1, %bb1.outer28.preheader ] | |
br label %bb1 | |
bb1: ; preds = %bb1, %bb1.outer28 | |
%front_active.0 = phi i8 [ %front_active.0.ph33, %bb1.outer28 ], [ 0, %bb1 ] | |
%12 = icmp eq i8 %front_active.0, 0 | |
br i1 %12, label %bb3, label %bb1 | |
bb3: ; preds = %bb1 | |
%13 = icmp ult i64 %b.sroa.0.0.ph29, %10 | |
br i1 %13, label %bb10, label %bb9 | |
bb6: ; preds = %bb6.preheader, %bb6 | |
%accum.0.ph51 = phi i64 [ %15, %bb6 ], [ 0, %bb6.preheader ] | |
%a.sroa.0.0.ph50 = phi i64 [ %14, %bb6 ], [ %5, %bb6.preheader ] | |
%14 = add i64 %a.sroa.0.0.ph50, 1 | |
%15 = tail call i64 %2(i64 %accum.0.ph51, i64 %a.sroa.0.0.ph50) | |
%16 = icmp ult i64 %14, %6 | |
br i1 %16, label %bb6, label %bb1.outer28.preheader.loopexit | |
bb9: ; preds = %bb3 | |
ret i64 %accum.0.ph32 | |
bb10: ; preds = %bb3 | |
%17 = add i64 %b.sroa.0.0.ph29, 1 | |
%18 = tail call i64 %2(i64 %accum.0.ph32, i64 %b.sroa.0.0.ph29) | |
br label %bb1.outer28 | |
} | |
; Function Attrs: nounwind | |
declare i32 @rust_eh_personality(i32, i32, i64, %"8.unwind::libunwind::_Unwind_Exception"*, %"8.unwind::libunwind::_Unwind_Context"*) unnamed_addr #1 | |
attributes #0 = { uwtable } | |
attributes #1 = { nounwind } |
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
#![crate_type="lib"] | |
use std::ops::Range; | |
#[no_mangle] | |
pub fn range_chain_default_fold(a: Range<usize>, b: Range<usize>, f: fn(usize, usize) -> usize) -> usize { | |
let mut accum = 0; | |
let mut a = a; | |
let mut b = b; | |
let mut front_active = true; | |
loop { | |
if front_active { | |
match a.next() { | |
Some(elt) => { | |
accum = f(accum, elt); | |
} | |
None => { | |
front_active = false; | |
continue; | |
} | |
} | |
} else { | |
let value = b.next(); | |
match value { | |
Some(elt) => accum = f(accum, elt), | |
None => break, | |
} | |
}; | |
} | |
accum | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment