diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2015-11-16 15:47:59 -0800 |
---|---|---|
committer | Eugene Rozenfeld <erozen@microsoft.com> | 2015-11-16 15:47:59 -0800 |
commit | 8284a530a90e921598479930c6fc1b9a0625b918 (patch) | |
tree | 1df8d6686a4438f12c6f47b93101a0cda381dccc | |
parent | 6a5862d9ff02af846fd25e216ff7948ecb7c49cc (diff) | |
download | coreclr-8284a530a90e921598479930c6fc1b9a0625b918.tar.gz coreclr-8284a530a90e921598479930c6fc1b9a0625b918.tar.bz2 coreclr-8284a530a90e921598479930c6fc1b9a0625b918.zip |
Fix for a rotation transformation bug.
rotatedValueBitSize should be calculated from genActualType(rotatedValue->gtType) instead of rotatedValue->gtType.
I added a test that was failing with an assert because of this bug: rol32ushort.
-rw-r--r-- | src/jit/morph.cpp | 5 | ||||
-rw-r--r-- | tests/src/JIT/CodeGenBringUpTests/Rotate.cs | 16 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 2d6d620a10..539f79f9db 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -12072,7 +12072,8 @@ GenTreePtr Compiler::fgRecognizeAndMorphBitwiseRotation(GenTreePtr tree) if (GenTree::Compare(leftShiftTree->gtGetOp1(), rightShiftTree->gtGetOp1())) { GenTreePtr rotatedValue = leftShiftTree->gtGetOp1(); - ssize_t rotatedValueBitSize = genTypeSize(rotatedValue->gtType) * 8; + var_types rotatedValueActualType = genActualType(rotatedValue->gtType); + ssize_t rotatedValueBitSize = genTypeSize(rotatedValueActualType) * 8; noway_assert((rotatedValueBitSize == 32) || (rotatedValueBitSize == 64)); GenTreePtr leftShiftIndex = leftShiftTree->gtGetOp2(); GenTreePtr rightShiftIndex = rightShiftTree->gtGetOp2(); @@ -12205,7 +12206,7 @@ GenTreePtr Compiler::fgRecognizeAndMorphBitwiseRotation(GenTreePtr tree) } else { - tree = gtNewOperNode(rotateOp, genActualType(rotatedValue->gtType), rotatedValue, rotateIndex); + tree = gtNewOperNode(rotateOp, rotatedValueActualType, rotatedValue, rotateIndex); noway_assert(inputTreeEffects == (tree->gtFlags & GTF_ALL_EFFECT)); } diff --git a/tests/src/JIT/CodeGenBringUpTests/Rotate.cs b/tests/src/JIT/CodeGenBringUpTests/Rotate.cs index 936718ce50..f5c2c04d15 100644 --- a/tests/src/JIT/CodeGenBringUpTests/Rotate.cs +++ b/tests/src/JIT/CodeGenBringUpTests/Rotate.cs @@ -14,6 +14,8 @@ public class Test volatile uint volatile_field; + ushort usfield; + [MethodImpl(MethodImplOptions.NoInlining)] static uint rol32(uint value, int amount) { @@ -166,10 +168,17 @@ public class Test return (value >> 10) | (value << 5); } - Test(ulong i, uint j) + [MethodImpl(MethodImplOptions.NoInlining)] + uint rol32ushort(int amount) + { + return ((uint)usfield << amount) | ((uint)usfield >> (32 - amount)); + } + + Test(ulong i, uint j, ushort k) { field = i; volatile_field = j; + usfield = k; } public static int Main() @@ -291,6 +300,11 @@ public class Test return Fail; } + if (test.rol32ushort(25) != 0x68000024) + { + return Fail; + } + return Pass; } } |