-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bit Shift Benchmark #279
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# ARGS: 3 5 10000 4 | ||
@pow(x: int, n: int): int { | ||
v1: int = id n; | ||
v2: int = const 1; | ||
v3: bool = eq v1 v2; | ||
br v3 .then.0 .else.0; | ||
.then.0: | ||
v4: int = id x; | ||
ret v4; | ||
jmp .endif.0; | ||
.else.0: | ||
v5: int = id x; | ||
v6: int = id n; | ||
v7: int = const 2; | ||
v8: int = div v6 v7; | ||
half: int = call @pow v5 v8; | ||
half: int = id half; | ||
v9: int = id half; | ||
v10: int = id half; | ||
v11: int = mul v9 v10; | ||
half2: int = id v11; | ||
v13: int = id n; | ||
v14: int = const 2; | ||
v15: int = call @mod v13 v14; | ||
v16: int = const 1; | ||
v17: bool = eq v15 v16; | ||
br v17 .then.12 .else.12; | ||
.then.12: | ||
v18: int = id half2; | ||
v19: int = id x; | ||
v20: int = mul v18 v19; | ||
ans: int = id v20; | ||
jmp .endif.12; | ||
.else.12: | ||
v21: int = id half2; | ||
ans: int = id v21; | ||
.endif.12: | ||
v22: int = id ans; | ||
ret v22; | ||
.endif.0: | ||
} | ||
@mod(a: int, b: int): int { | ||
v0: int = id a; | ||
v1: int = id a; | ||
v2: int = id b; | ||
v3: int = div v1 v2; | ||
v4: int = id b; | ||
v5: int = mul v3 v4; | ||
v6: int = sub v0 v5; | ||
ret v6; | ||
} | ||
@LEFTSHIFT(x: int, step: int): int { | ||
v0: int = const 2; | ||
v1: int = id step; | ||
p: int = call @pow v0 v1; | ||
p: int = id p; | ||
v2: int = id x; | ||
v3: int = id p; | ||
v4: int = mul v2 v3; | ||
ret v4; | ||
} | ||
@RIGHTSHIFT(x: int, step: int): int { | ||
v0: int = const 2; | ||
v1: int = id step; | ||
p: int = call @pow v0 v1; | ||
p: int = id p; | ||
v2: int = id x; | ||
v3: int = id p; | ||
v4: int = div v2 v3; | ||
ret v4; | ||
} | ||
@main(a: int, b: int, c: int, d: int) { | ||
v2: int = id a; | ||
v3: int = id b; | ||
ans1: int = call @LEFTSHIFT v2 v3; | ||
print ans1; | ||
v4: int = id c; | ||
v5: int = id d; | ||
ans2: int = call @RIGHTSHIFT v4 v5; | ||
print ans2; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
96 | ||
625 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
total_dyn_inst: 167 |
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider removing this dead jump and associated label? While this doesn't affect an interpreter, this trips up both
brilift
andbrillvm
as during compilation they get tricked in generating empty returns for the final label.This could be fixed in both tools, but it's kind of a weird edge case the more I looked into it. I lean more towards this should be avoided in benchmark files than this is worth the added complexity in the above tools.
Is this a bug in the typescript compiler?
Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question about whether this is something the TypeScript compiler should avoid… maybe a good step for investigating this would be to try to reproduce it with a minimal TS program that produces this weird CFG pattern?