mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86emul: simplify SHLD/SHRD handling
First of all there's no point considering the "shift == width" case, when immediately before that check we mask "shift" by "width - 1". And then truncate_word() use can be reduced too: dst.val, as obtained by generic operand fetching code, is already suitably truncated, and its use can also be made symmetric in the main conditional expression (on only left shift results). Finally masking the result of a right shift is not necessary when the left hand operand doesn't have more than "width" significant bits. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
579d698da6
commit
4e59f578cb
1 file changed
+8
-10
@@ -6414,16 +6414,14 @@ x86_emulate(
|
||||
}
|
||||
if ( (shift &= width - 1) == 0 )
|
||||
break;
|
||||
dst.orig_val = truncate_word(dst.val, dst.bytes);
|
||||
dst.val = ((shift == width) ? src.val :
|
||||
(b & 8) ?
|
||||
/* shrd */
|
||||
((dst.orig_val >> shift) |
|
||||
truncate_word(src.val << (width - shift), dst.bytes)) :
|
||||
/* shld */
|
||||
((dst.orig_val << shift) |
|
||||
((src.val >> (width - shift)) & ((1ull << shift) - 1))));
|
||||
dst.val = truncate_word(dst.val, dst.bytes);
|
||||
dst.orig_val = dst.val;
|
||||
dst.val = (b & 8) ?
|
||||
/* shrd */
|
||||
((dst.orig_val >> shift) |
|
||||
truncate_word(src.val << (width - shift), dst.bytes)) :
|
||||
/* shld */
|
||||
(truncate_word(dst.orig_val << shift, dst.bytes) |
|
||||
(src.val >> (width - shift)));
|
||||
_regs.eflags &= ~(X86_EFLAGS_OF | X86_EFLAGS_SF | X86_EFLAGS_ZF |
|
||||
X86_EFLAGS_PF | X86_EFLAGS_CF);
|
||||
if ( (dst.val >> ((b & 8) ? (shift - 1) : (width - shift))) & 1 )
|
||||
|
||||