Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 01568d5

Browse files
committed
[X86] Use a MOVSX instruction instead of a MOVZX instruction in isel for an any_extend of the remainder from an 8-bit sdivrem.
The sdivrem will emit its own MOVSX to move %ah to the low byte of a register. By using a MOVSX for an any_extend this allows a post-isel peephole to merge them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346581 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6c3e6aa commit 01568d5

File tree

2 files changed

+87
-152
lines changed

2 files changed

+87
-152
lines changed

lib/Target/X86/X86InstrCompiler.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,15 @@ def : Pat<(i64 (anyext GR16:$src)),
13201320
def : Pat<(i64 (anyext GR32:$src)),
13211321
(INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, sub_32bit)>;
13221322

1323+
// If this is an anyext of the remainder of an 8-bit sdivrem, use a MOVSX
1324+
// instead of a MOVZX. The sdivrem lowering will emit emit a MOVSX to move
1325+
// %ah to the lower byte of a register. By using a MOVSX here we allow a
1326+
// post-isel peephole to merge the two MOVSX instructions into one.
1327+
def anyext_sdiv : PatFrag<(ops node:$lhs), (anyext node:$lhs),[{
1328+
return (N->getOperand(0).getOpcode() == ISD::SDIVREM &&
1329+
N->getOperand(0).getResNo() == 1);
1330+
}]>;
1331+
def : Pat<(i32 (anyext_sdiv GR8:$src)), (MOVSX32rr8 GR8:$src)>;
13231332

13241333
// Any instruction that defines a 32-bit result leaves the high half of the
13251334
// register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may

0 commit comments

Comments
 (0)