diff options
author | Mike Danes <onemihaid@hotmail.com> | 2018-01-27 22:09:52 +0200 |
---|---|---|
committer | Mike Danes <onemihaid@hotmail.com> | 2018-02-12 22:32:48 +0200 |
commit | 0880a64ed1f932f65e21618661baab3ce9c60162 (patch) | |
tree | 9aa555288a24bb98ab929a36675bffc0a49baae7 /src/jit/gentree.h | |
parent | 1e9f9ab12d58d2cd465891be7524d3b132704d64 (diff) | |
download | coreclr-0880a64ed1f932f65e21618661baab3ce9c60162.tar.gz coreclr-0880a64ed1f932f65e21618661baab3ce9c60162.tar.bz2 coreclr-0880a64ed1f932f65e21618661baab3ce9c60162.zip |
Fix inconsistent handling of zero extending casts
For casts that are supposed to zero extend the GTF_UNSIGNED must always be set (and obeyed).
Some code failed to set the flag (e.g. when importing add.ovf.un instructions having native int and int32 operands) and some other code failed to check the flag (e.g. x64 codegen, gtFoldExprConst) and instead decided to zero extend based on the cast destination type.
This resulted in discrepancies between ARM64 and x64 codegen and between constant folding performed by gtFoldExprConst and VN's EvalCastForConstantArgs.
Diffstat (limited to 'src/jit/gentree.h')
-rw-r--r-- | src/jit/gentree.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 5f534db8f1..5a27b389dd 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -2993,9 +2993,10 @@ struct GenTreeCast : public GenTreeOp } var_types gtCastType; - GenTreeCast(var_types type, GenTree* op, var_types castType DEBUGARG(bool largeNode = false)) + GenTreeCast(var_types type, GenTree* op, bool fromUnsigned, var_types castType DEBUGARG(bool largeNode = false)) : GenTreeOp(GT_CAST, type, op, nullptr DEBUGARG(largeNode)), gtCastType(castType) { + gtFlags |= fromUnsigned ? GTF_UNSIGNED : 0; } #if DEBUGGABLE_GENTREE GenTreeCast() : GenTreeOp() |