public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/44588]  New: Very inefficient 8bit mod/div
@ 2010-06-19  0:49 hjl dot tools at gmail dot com
  2010-06-19  0:52 ` [Bug target/44588] " hjl dot tools at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-19  0:49 UTC (permalink / raw)
  To: gcc-bugs

On x86, I got

[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]$ gcc -S -O3 umod-2.c
[hjl@gnu-6 divb]$ cat umod-2.s
        .file   "umod-2.c"
        .text
        .p2align 4,,15
.globl foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
        movzbl  %dil, %edi
        movzbl  %sil, %ecx
        xorl    %edx, %edx
        movl    %edi, %eax
        divb    %sil
        movb    %al, z(%rip)
        movl    %edi, %eax
        divw    %cx
        movl    %edx, %eax
        ret


-- 
           Summary: Very inefficient 8bit mod/div
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
@ 2010-06-19  0:52 ` hjl dot tools at gmail dot com
  2010-06-19 19:04 ` hjl dot tools at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-19  0:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hjl dot tools at gmail dot com  2010-06-19 00:52 -------
Created an attachment (id=20941)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20941&action=view)
A patch

With this patch, I got

foo:
.LFB0:
        .cfi_startproc
        movl    %edi, %eax
        divb    %sil
        movb    %al, z(%rip)
        movsbl  %ah, %eax
        ret


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
  2010-06-19  0:52 ` [Bug target/44588] " hjl dot tools at gmail dot com
@ 2010-06-19 19:04 ` hjl dot tools at gmail dot com
  2010-06-20  1:59 ` hjl dot tools at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-19 19:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hjl dot tools at gmail dot com  2010-06-19 19:03 -------
Created an attachment (id=20943)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20943&action=view)
An updated patch

8bit divide is AX / r/m8. Here is the updated patch.
Now it generates:

foo:
.LFB0:
        .cfi_startproc
        movzbl  %dil, %eax
        divb    %sil
        movzbl  %al, %edx
        movzbl  %ah, %eax
        movb    %dl, z(%rip)
        ret


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #20941|0                           |1
        is obsolete|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
  2010-06-19  0:52 ` [Bug target/44588] " hjl dot tools at gmail dot com
  2010-06-19 19:04 ` hjl dot tools at gmail dot com
@ 2010-06-20  1:59 ` hjl dot tools at gmail dot com
  2010-06-22 17:30 ` hjl dot tools at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-20  1:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl dot tools at gmail dot com  2010-06-20 01:59 -------
Created an attachment (id=20944)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20944&action=view)
Another update

This patch removes EFLAGS clobber for sign extend.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #20943|0                           |1
        is obsolete|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
                   ` (2 preceding siblings ...)
  2010-06-20  1:59 ` hjl dot tools at gmail dot com
@ 2010-06-22 17:30 ` hjl dot tools at gmail dot com
  2010-06-24 18:20 ` hjl at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-22 17:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hjl dot tools at gmail dot com  2010-06-22 17:30 -------
The patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2010-06/msg02200.html


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2010-
                   |                            |06/msg02200.html


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
                   ` (3 preceding siblings ...)
  2010-06-22 17:30 ` hjl dot tools at gmail dot com
@ 2010-06-24 18:20 ` hjl at gcc dot gnu dot org
  2010-06-24 18:21 ` hjl at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu dot org @ 2010-06-24 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from hjl at gcc dot gnu dot org  2010-06-24 18:20 -------
Subject: Bug 44588

Author: hjl
Date: Thu Jun 24 18:20:28 2010
New Revision: 161329

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161329
Log:
Implement 8bit divmod patterns.

gcc/

2010-06-24  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/44588
        * config/i386/i386.md (extract_code): New.
        (<u>divmodqi4): Likewise.
        (divmodhiqi3): Likewise.
        (udivmodhiqi3): Likewise.
        (<u>divqi3): Remvoved.

gcc/testsuite/

2010-06-24  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/44588
        * gcc.target/i386/mod-1.c: New.
        * gcc.target/i386/umod-1.c: Likewise.
        * gcc.target/i386/umod-2.c: Likewise.
        * gcc.target/i386/umod-3.c: Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.md
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
                   ` (4 preceding siblings ...)
  2010-06-24 18:20 ` hjl at gcc dot gnu dot org
@ 2010-06-24 18:21 ` hjl at gcc dot gnu dot org
  2010-07-07 21:12 ` hjl at gcc dot gnu dot org
  2010-07-07 21:43 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu dot org @ 2010-06-24 18:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from hjl at gcc dot gnu dot org  2010-06-24 18:21 -------
Subject: Bug 44588

Author: hjl
Date: Thu Jun 24 18:21:21 2010
New Revision: 161330

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161330
Log:
Add missing testcases for PR 44588.

Added:
    trunk/gcc/testsuite/gcc.target/i386/mod-1.c
    trunk/gcc/testsuite/gcc.target/i386/umod-1.c
    trunk/gcc/testsuite/gcc.target/i386/umod-2.c
    trunk/gcc/testsuite/gcc.target/i386/umod-3.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
                   ` (5 preceding siblings ...)
  2010-06-24 18:21 ` hjl at gcc dot gnu dot org
@ 2010-07-07 21:12 ` hjl at gcc dot gnu dot org
  2010-07-07 21:43 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu dot org @ 2010-07-07 21:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl at gcc dot gnu dot org  2010-07-07 21:11 -------
Subject: Bug 44588

Author: hjl
Date: Wed Jul  7 21:11:25 2010
New Revision: 161933

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161933
Log:
Backport 8bit div/mod improvements.

gcc/

2010-07-07  H.J. Lu  <hongjiu.lu@intel.com>

        Backport from mainline
        2010-07-04  H.J. Lu  <hongjiu.lu@intel.com>

        PR rtl-optimization/44695
        * config/i386/i386.md (extract_code): Removed.
        (<u>divmodqi4): Likewise.
        (divmodqi4): New.
        (udivmodqi4): Likewise.
        (divmodhiqi3): Change div/mod to HImode and extend operand 2 to
        HImode.
        (udivmodhiqi3): Likewise.

        2010-06-24  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/44588
        * config/i386/i386.md (extract_code): New.
        (<u>divmodqi4): Likewise.
        (divmodhiqi3): Likewise.
        (udivmodhiqi3): Likewise.
        (<u>divqi3): Remvoved.

gcc/testsuite/

2010-07-07  H.J. Lu  <hongjiu.lu@intel.com>

        Backport from mainline
        2010-07-04  H.J. Lu  <hongjiu.lu@intel.com>

        PR rtl-optimization/44695
        * gcc.dg/torture/pr44695.c: New.

        2010-06-24  H.J. Lu  <hongjiu.lu@intel.com>

        PR target/44588
        * gcc.target/i386/mod-1.c: New.
        * gcc.target/i386/umod-1.c: Likewise.
        * gcc.target/i386/umod-2.c: Likewise.
        * gcc.target/i386/umod-3.c: Likewise.

Modified:
    branches/ix86/gcc-4_5-branch/gcc/config/i386/i386.md


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/44588] Very inefficient 8bit mod/div
  2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
                   ` (6 preceding siblings ...)
  2010-07-07 21:12 ` hjl at gcc dot gnu dot org
@ 2010-07-07 21:43 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-07-07 21:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hjl dot tools at gmail dot com  2010-07-07 21:42 -------
Fixed.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-07-07 21:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-19  0:49 [Bug target/44588] New: Very inefficient 8bit mod/div hjl dot tools at gmail dot com
2010-06-19  0:52 ` [Bug target/44588] " hjl dot tools at gmail dot com
2010-06-19 19:04 ` hjl dot tools at gmail dot com
2010-06-20  1:59 ` hjl dot tools at gmail dot com
2010-06-22 17:30 ` hjl dot tools at gmail dot com
2010-06-24 18:20 ` hjl at gcc dot gnu dot org
2010-06-24 18:21 ` hjl at gcc dot gnu dot org
2010-07-07 21:12 ` hjl at gcc dot gnu dot org
2010-07-07 21:43 ` hjl dot tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).