summaryrefslogtreecommitdiff
path: root/src/jit/instrsxarch.h
diff options
context:
space:
mode:
authorEugene Rozenfeld <erozen@microsoft.com>2015-10-12 18:36:25 -0700
committerEugene Rozenfeld <erozen@microsoft.com>2015-10-21 18:51:48 -0700
commit7b4508ba9419157570a9c47e4ebc8a79dcc53a11 (patch)
treecf3feb736ff173462fc82b71633f2d66e75ee9cc /src/jit/instrsxarch.h
parent65b55ab02eba5fc71daadb0db9f4d4a424906dba (diff)
downloadcoreclr-7b4508ba9419157570a9c47e4ebc8a79dcc53a11.tar.gz
coreclr-7b4508ba9419157570a9c47e4ebc8a79dcc53a11.tar.bz2
coreclr-7b4508ba9419157570a9c47e4ebc8a79dcc53a11.zip
Generate efficient code for rotation patterns.
This change adds code to recognize rotation idioms and generate efficient instructions for them. Two new operators are added: GT_ROL and GT_ROR. The patterns recognized: (x << c1) | (x >>> c2) => x rol c1 (x >>> c1) | (x << c2) => x ror c2 where c1 and c2 are constant and c1 + c2 == bitsize(x) (x << y) | (x >>> (N - y)) => x rol y (x >>> y) | (x << (N - y)) => x ror y where N == bitsize(x) (x << y & M1) | (x >>> (N - y) & M2) => x rol y (x >>> y & M1) | (x << (N - y) & M2) => x ror y where N == bitsize(x) M1 & (N - 1) == N - 1 M2 & (N - 1) == N - 1 For a simple benchmark with 4 rotation patterns in a tight loop time goes from 7.324 to 2.600 (2.8 speedup). Rotations found and optimized in mscorlib: System.Security.Cryptography.SHA256Managed::RotateRight System.Security.Cryptography.SHA384Managed::RotateRight System.Security.Cryptography.SHA512Managed::RotateRight System.Security.Cryptography.RIPEMD160Managed:MDTransform (320 instances!) System.Diagnostics.Tracing.EventSource.Sha1ForNonSecretPurposes::Rol1 System.Diagnostics.Tracing.EventSource.Sha1ForNonSecretPurposes::Rol5 System.Diagnostics.Tracing.EventSource.Sha1ForNonSecretPurposes::Rol30 System.Diagnostics.Tracing.EventSource.Sha1ForNonSecretPurposes::Drain (9 instances of Sha1ForNonSecretPurposes::Rol* inlined) Closes #1619.
Diffstat (limited to 'src/jit/instrsxarch.h')
-rw-r--r--src/jit/instrsxarch.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/jit/instrsxarch.h b/src/jit/instrsxarch.h
index c0be9aae73..9f8a9956a3 100644
--- a/src/jit/instrsxarch.h
+++ b/src/jit/instrsxarch.h
@@ -339,6 +339,13 @@ INST2(ret , "ret" , 0, IUM_RD, 0, 0, 0x0000C3, 0x0000C2)
INST2(loop , "loop" , 0, IUM_RD, 0, 0, BAD_CODE, 0x0000E2)
INST2(call , "call" , 0, IUM_RD, 0, 1, 0x0010FF, 0x0000E8)
+INST2(rol , "rol" , 0, IUM_RW, 0, 1, 0x0000D2, BAD_CODE)
+INST2(rol_1 , "rol" , 0, IUM_RW, 0, 1, 0x0000D0, 0x0000D0)
+INST2(rol_N , "rol" , 0, IUM_RW, 0, 1, 0x0000C0, 0x0000C0)
+INST2(ror , "ror" , 0, IUM_RW, 0, 1, 0x0008D2, BAD_CODE)
+INST2(ror_1 , "ror" , 0, IUM_RW, 0, 1, 0x0008D0, 0x0008D0)
+INST2(ror_N , "ror" , 0, IUM_RW, 0, 1, 0x0008C0, 0x0008C0)
+
INST2(rcl , "rcl" , 0, IUM_RW, 1, 1, 0x0010D2, BAD_CODE)
INST2(rcl_1 , "rcl" , 0, IUM_RW, 1, 1, 0x0010D0, 0x0010D0)
INST2(rcl_N , "rcl" , 0, IUM_RW, 1, 1, 0x0010C0, 0x0010C0)