Created
May 15, 2018 09:03
-
-
Save ramntry/f3aa15e826660bebc94d0acc59dfd29d 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
define i64 @test_phi_loop(i32 %n) { | |
entry: | |
br label %loop | |
loop: | |
%counter = phi i32 [ %n, %entry ], [ %counter.dec, %loop ] | |
%elem = phi { i64, i64 } [ { i64 0, i64 1 }, %entry ], [ %updated, %loop ] | |
%prev = extractvalue { i64, i64 } %elem, 0 | |
%curr = extractvalue { i64, i64 } %elem, 1 | |
%next = add i64 %prev, %curr | |
%shifted = insertvalue { i64, i64 } %elem, i64 %curr, 0 | |
%updated = insertvalue { i64, i64 } %shifted, i64 %next, 1 | |
%counter.dec = sub i32 %counter, 1 | |
%cond = icmp sle i32 %counter, 0 | |
br i1 %cond, label %exit, label %loop | |
exit: | |
%res = extractvalue { i64, i64 } %elem, 0 | |
ret i64 %res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment