Last active
October 29, 2016 00:46
-
-
Save leppie/66d8226262f2ebda55e9fd6a6937fa7e to your computer and use it in GitHub Desktop.
int32 rotation in ironscheme
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
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Running; | |
| public class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| BenchmarkRunner.Run<Program>(); | |
| } | |
| [Benchmark(Baseline = true)] | |
| public static void R() | |
| { | |
| fxrotate(); | |
| } | |
| static int fxrotate(int n = 41, int start = 0, int end = 5, int count = 1) | |
| { | |
| int num = n; | |
| int num2 = start; | |
| int num3 = end; | |
| int num4 = count; | |
| int num5 = num3 - num2; | |
| int num6 = num; | |
| int num7 = num2; | |
| int num8 = num3 - num4; | |
| int num9 = (num6 & ~(-1 << num8)) >> num7; | |
| int num10 = num; | |
| int num11 = num2; | |
| int num12 = num3; | |
| int num13 = (num10 & ~(-1 << num12)) >> num11; | |
| int num14 = num; | |
| int num15 = num2; | |
| int num16 = num3; | |
| int num17 = (num9 << num4) | (num13 >> (num5 - num4)); | |
| int num18 = (-1 << num15) & ~(-1 << num16); | |
| int num19 = num17 << num15; | |
| int num20 = num14; | |
| return (num18 & num19) | (~num18 & num20); | |
| } | |
| [Benchmark] | |
| public static void R_opt() | |
| { | |
| fxrotate_opt(); | |
| } | |
| static int fxrotate_opt(int n = 41, int start = 0, int end = 5, int count = 1) | |
| { | |
| int r = (-1 << start) & ~(-1 << end); | |
| return (r & | |
| (((n & ~(-1 << end - count)) >> start << count) | ((n & ~(-1 << end)) >> start >> (end - start - count))) << | |
| start) | (~r & n); | |
| } | |
| } |
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
| public static object ironscheme.arithmetic.fixnums::fxrotate-bit-field(object n, object start, object end, object count) | |
| { | |
| int num = (int) n; | |
| int num2 = (int) start; | |
| int num3 = (int) end; | |
| int num4 = (int) count; | |
| int num5 = num3 - num2; | |
| int num6 = num; | |
| int num7 = num2; | |
| int num8 = num3 - num4; | |
| int num9 = (num6 & ~(-1 << num8)) >> num7; | |
| int num10 = num; | |
| int num11 = num2; | |
| int num12 = num3; | |
| int num13 = (num10 & ~(-1 << num12)) >> num11; | |
| int num14 = num; | |
| int num15 = num2; | |
| int num16 = num3; | |
| int num17 = (num9 << num4) | (num13 >> (num5 - num4)); | |
| int num18 = (-1 << num15) & ~(-1 << num16); | |
| int num19 = num17 << num15; | |
| int num20 = num14; | |
| return (num18 & num19) | (~num18 & num20); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment