diff options
author | Sejong Oh <sejong.oh.25911@outlook.com> | 2016-01-07 15:41:10 -0800 |
---|---|---|
committer | Sejong Oh <sejong.oh.25911@outlook.com> | 2016-01-07 15:41:10 -0800 |
commit | 63268a3bd162acfba9ad41ea5209d6a069527c20 (patch) | |
tree | 417e8490227ec2b4bea0cb340c0d4dc6f4159e41 /src/jit/lowerxarch.cpp | |
parent | ee1a606cc4a97ea39a7d97d999c0a2f8e4c12d23 (diff) | |
download | coreclr-63268a3bd162acfba9ad41ea5209d6a069527c20.tar.gz coreclr-63268a3bd162acfba9ad41ea5209d6a069527c20.tar.bz2 coreclr-63268a3bd162acfba9ad41ea5209d6a069527c20.zip |
Fix wrong codegen for comparing 16-bit unsigned values
The changes fix a bug generating 16-bit signed comparison code to
compare unsigned 16-bit values.
Diffstat (limited to 'src/jit/lowerxarch.cpp')
-rw-r--r-- | src/jit/lowerxarch.cpp | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/src/jit/lowerxarch.cpp b/src/jit/lowerxarch.cpp index 14412b7f66..369f81b7bd 100644 --- a/src/jit/lowerxarch.cpp +++ b/src/jit/lowerxarch.cpp @@ -2884,40 +2884,27 @@ void Lowering::LowerCmp(GenTreePtr tree) } } } - else if (op2->isMemoryOp()) - { - if (op1Type == op2Type) - { - MakeSrcContained(tree, op2); - - // Mark the tree as doing unsigned comparison if - // both the operands are small and unsigned types. - // Otherwise we will end up performing a signed comparison - // of two small unsigned values without zero extending them to - // TYP_INT size and which is incorrect. - if (varTypeIsSmall(op1Type) && varTypeIsUnsigned(op1Type)) - { - tree->gtFlags |= GTF_UNSIGNED; - } - } - } - else if (op1->isMemoryOp()) - { - if ((op1Type == op2Type) && IsSafeToContainMem(tree, op1)) - { - MakeSrcContained(tree, op1); - - // Mark the tree as doing unsigned comparison if - // both the operands are small and unsigned types. - // Otherwise we will end up performing a signed comparison - // of two small unsigned values without zero extending them to - // TYP_INT size and which is incorrect. - if (varTypeIsSmall(op1Type) && varTypeIsUnsigned(op1Type)) - { - tree->gtFlags |= GTF_UNSIGNED; - } - } - } + else if (op1Type == op2Type) + { + if (op2->isMemoryOp()) + { + MakeSrcContained(tree, op2); + } + else if (op1->isMemoryOp() && IsSafeToContainMem(tree, op1)) + { + MakeSrcContained(tree, op1); + } + + if (varTypeIsSmall(op1Type) && varTypeIsUnsigned(op1Type)) + { + // Mark the tree as doing unsigned comparison if + // both the operands are small and unsigned types. + // Otherwise we will end up performing a signed comparison + // of two small unsigned values without zero extending them to + // TYP_INT size and which is incorrect. + tree->gtFlags |= GTF_UNSIGNED; + } + } } /* Lower GT_CAST(srcType, DstType) nodes. |