Created
December 11, 2012 10:09
-
-
Save nddrylliog/4257529 to your computer and use it in GitHub Desktop.
Scissors handling some conditionals
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
=========================== | |
Dice roll... 4! | |
=========================== | |
--------------------------- | |
old body = {4 } | |
new body = {a : <unknown type> = 1, b : <unknown type> = 2, c : <unknown type> = 3, b > a ? (c > b ? c : b) : a } | |
--------------------------- | |
[scissors] Done tinkering | |
[scissors] resolved body = {a : SSizeT = 1, b : SSizeT = 2, c : SSizeT = 3, return b > a ? (c > b ? c : b) : a as Int } | |
; ModuleID = 'scissors' | |
define i32 @scissors() { | |
entry: | |
%a = alloca i64 | |
store i64 1, i64* %a | |
%b = alloca i64 | |
store i64 2, i64* %b | |
%c = alloca i64 | |
store i64 3, i64* %c | |
%bLoad = load i64* %b | |
%aLoad = load i64* %a | |
%comptmp = icmp sgt i64 %bLoad, %aLoad | |
%cast = sitofp i1 %comptmp to double | |
%ternCond = fcmp one double %cast, 0.000000e+00 | |
br i1 %ternCond, label %then, label %else | |
then: ; preds = %entry | |
%cLoad = load i64* %c | |
%bLoad1 = load i64* %b | |
%comptmp2 = icmp sgt i64 %cLoad, %bLoad1 | |
%cast3 = sitofp i1 %comptmp2 to double | |
%ternCond4 = fcmp one double %cast3, 0.000000e+00 | |
br i1 %ternCond4, label %then5, label %else6 | |
else: ; preds = %entry | |
%aLoad10 = load i64* %a | |
br label %merge | |
merge: ; preds = %else, %merge7 | |
%iftmp11 = phi i64 [ %iftmp, %merge7 ], [ %aLoad10, %else ] | |
%castResult = trunc i64 %iftmp11 to i32 | |
ret i32 %castResult | |
then5: ; preds = %then | |
%cLoad8 = load i64* %c | |
br label %merge7 | |
else6: ; preds = %then | |
%bLoad9 = load i64* %b | |
br label %merge7 | |
merge7: ; preds = %else6, %then5 | |
%iftmp = phi i64 [ %cLoad8, %then5 ], [ %bLoad9, %else6 ] | |
br label %merge | |
} | |
================================== | |
Post-optimization, module = | |
================================== | |
; ModuleID = 'scissors' | |
define i32 @scissors() { | |
entry: | |
br i1 true, label %then, label %else | |
then: ; preds = %entry | |
br i1 true, label %then5, label %else6 | |
else: ; preds = %entry | |
br label %merge | |
merge: ; preds = %else, %merge7 | |
%iftmp11 = phi i64 [ %iftmp, %merge7 ], [ 1, %else ] | |
%castResult = trunc i64 %iftmp11 to i32 | |
ret i32 %castResult | |
then5: ; preds = %then | |
br label %merge7 | |
else6: ; preds = %then | |
br label %merge7 | |
merge7: ; preds = %else6, %then5 | |
%iftmp = phi i64 [ 3, %then5 ], [ 2, %else6 ] | |
br label %merge | |
} | |
Got function at address 0x7db4010 | |
=========================== | |
Dice roll... 3! | |
=========================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment