On Mon, Jun 21, 2010 at 12:33 PM, H.J. Lu wrote: > Hi, > > This patch adds 8bit divmov pattern for x86. X86 8bit divide > instructions return result in AX with > > AL <- Quotient > AH <- Remainder > > This patch models it and properly extends quotient. Tested > on Intel64 with -m64 and -m32.  There are no regressions. > OK for trunk? > > BTW, there is only one divb used in subreg_get_info in > gcc compilers. The old code is > >        movzbl  mode_size(%r13), %edi >        movzbl  mode_size(%r14), %esi >        xorl    %edx, %edx >        movl    %edi, %eax >        divw    %si >        testw   %dx, %dx >        jne     .L1194 > > The new one is > >        movzbl  mode_size(%r13), %edi >        movl    %edi, %eax >        divb    mode_size(%r14) >        movzbl  %ah, %eax >        testb   %al, %al >        jne     .L1194 > > Thanks. > > > H.J. > --- > gcc/ > > 2010-06-21  H.J. Lu   > >        PR target/44588 >        * config/i386/i386.md (UNSPEC_MOVQI_EXTZV): New. >        (any_div_code): Likewise. >        (extend_code): Likewise. >        (extract_code): Likewise. >        (*movqi_extzv_3): Likewise. >        (*movqi_extzv_3_rex64): Likewise. >        (*movqi_extzv): Likewise. >        (divmodqi4): Likewise. >        (*divqi3): Likewise. >        (divqi3): Remvoved. > > gcc/testsuite/ > > 2010-06-21  H.J. Lu   > >        PR target/44588 >        * gcc.target/i386/umod-1.c: New. >        * gcc.target/i386/umod-2.c: Likewise. >        * gcc.target/i386/umod-3.c: Likewise. > Here is the updated patch. It uses UNSPEC to extract remainder in AH from AL. If we only need quotient, it will be in AL. Now we generate: [hjl@gnu-6 divb]$ cat umod-2.c extern unsigned char z; unsigned char foo (unsigned char x, unsigned char y) { z = x/y; return x % y; } [hjl@gnu-6 divb]$ make umod-2.s /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -Os -S umod-2.c [hjl@gnu-6 divb]$ cat umod-2.s .file "umod-2.c" .text .globl foo .type foo, @function foo: .LFB0: .cfi_startproc movzbl %dil, %eax divb %sil movb %al, z(%rip) movzbl %ah, %eax ret OK for trunk? Thanks. -- H.J. --- gcc/ 2010-06-22 H.J. Lu PR target/44588 * config/i386/i386.md (UNSPEC_MOVQI_EXTZH): New. (any_div_code): Likewise. (extend_code): Likewise. (extract_code): Likewise. (*movqi_extzh): Likewise. (*movqi_extzh_rex64): Likewise. (divmodqi4): Likewise. (*divqi3): Likewise. (divqi3): Remvoved. gcc/testsuite/ 2010-06-22 H.J. Lu PR target/44588 * gcc.target/i386/umod-1.c: New. * gcc.target/i386/umod-2.c: Likewise. * gcc.target/i386/umod-3.c: Likewise.