[X86] 8bit divrem: Improve codegen for AH register extraction.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Mon, 3 Nov 2014 20:26:35 +0000 (20:26 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Mon, 3 Nov 2014 20:26:35 +0000 (20:26 +0000)
commit12eb558bd96a155fa9a1bbf9a27676571f23f7d0
treeacb803d8e20af717c4b7674bc38072800caf3eba
parent1e16fa302e2c3f68ea8187e8b782397e0b24cd0f
[X86] 8bit divrem: Improve codegen for AH register extraction.

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).

Differential Revision: http://reviews.llvm.org/D6064

llvm-svn: 221176
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrExtension.td
llvm/test/CodeGen/X86/divrem8_ext.ll [new file with mode: 0644]