[PATCH] [X86] 8bit divrem: Improve codegen for AH register extraction.
Ahmed Bougacha
ahmed.bougacha at gmail.com
Fri Oct 31 13:30:09 PDT 2014
Hi lhames, qcolombet,
For 8-bit divrems where the remainder is used, we used to generate:
divb %sil
shrw $8, %ax
movzbl %al, %eax
That was to avoid an H-reg access, which is problematic mainly because
it isn't possible in REX-prefixed instructions.
This patch optimizes that to:
divb %sil
movzbl %ah, %eax
To do that, we explicitly extend AH, and extract the L-subreg in the
resulting register. The extension is done using the NOREX variants of
MOVZX. To support signed operations, MOVSX_NOREX is also added.
Further, this introduces a new SDNode type, [us]divrem_ext_hreg, which is
then lowered to a sequence containing a single zext (rather than 2).
The new node isn't ideal, but I'm not aware of any alternatives to avoid redundant extensions.
http://reviews.llvm.org/D6064
Files:
lib/Target/X86/X86ISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrExtension.td
test/CodeGen/X86/divrem8_ext.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6064.15643.patch
Type: text/x-patch
Size: 11090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141031/592d7210/attachment.bin>
More information about the llvm-commits
mailing list