public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/44382] New: Slow integer multiply
@ 2010-06-02 15:04 hjl dot tools at gmail dot com
2010-06-02 15:15 ` [Bug middle-end/44382] " rguenth at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-02 15:04 UTC (permalink / raw)
To: gcc-bugs
For
---
extern int a, b, c, d, e, f;
void
foo ()
{
a = f * b * c * d;
}
---
on Linux/x86-64, gcc generates:
movl b(%rip), %eax
imull f(%rip), %eax
imull c(%rip), %eax
imull d(%rip), %eax
movl %eax, a(%rip)
ret
Icc generates:
movl c(%rip), %eax #6.15
movl f(%rip), %edx #6.7
imull d(%rip), %eax #6.19
imull b(%rip), %edx #6.11
imull %eax, %edx #6.15
movl %edx, a(%rip) #6.3
ret #7.1
Icc version is faster since 2 multiplications may
be issued at the same time.
--
Summary: Slow integer multiply
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: middle-end
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=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
@ 2010-06-02 15:15 ` rguenth at gcc dot gnu dot org
2010-06-04 13:08 ` hjl dot tools at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-02 15:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2010-06-02 15:15 -------
Because our tree reassoc doesn't re-associate them.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2010-06-02 15:15:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
2010-06-02 15:15 ` [Bug middle-end/44382] " rguenth at gcc dot gnu dot org
@ 2010-06-04 13:08 ` hjl dot tools at gmail dot com
2010-06-04 13:21 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-04 13:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from hjl dot tools at gmail dot com 2010-06-04 13:08 -------
(In reply to comment #1)
> Because our tree reassoc doesn't re-associate them.
>
The tree reassoc pass makes it slower:
[hjl@gnu-6 44382]$ cat x.i
extern int a, b, c, d, e, f;
void
foo ()
{
a = (b * c) * (d * e);
}
[hjl@gnu-6 44382]$ gcc -S -O2 x.i
[hjl@gnu-6 44382]$ cat x.s
.file "x.i"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl c(%rip), %eax
imull b(%rip), %eax
imull d(%rip), %eax
imull e(%rip), %eax
movl %eax, a(%rip)
ret
[hjl@gnu-6 44382]$ gcc -S -O2 x.i -fno-tree-reassoc
[hjl@gnu-6 44382]$ cat x.s
.file "x.i"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl b(%rip), %eax
movl d(%rip), %edx
imull c(%rip), %eax
imull e(%rip), %edx
imull %edx, %eax
movl %eax, a(%rip)
ret
[hjl@gnu-6 44382]$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
2010-06-02 15:15 ` [Bug middle-end/44382] " rguenth at gcc dot gnu dot org
2010-06-04 13:08 ` hjl dot tools at gmail dot com
@ 2010-06-04 13:21 ` rguenth at gcc dot gnu dot org
2010-06-04 13:57 ` hjl dot tools at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-04 13:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-06-04 13:21 -------
Yes, reassoc linearizes instead of building a tree (saves one (or was it two?)
registers at best).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
` (2 preceding siblings ...)
2010-06-04 13:21 ` rguenth at gcc dot gnu dot org
@ 2010-06-04 13:57 ` hjl dot tools at gmail dot com
2010-06-04 14:40 ` hjl dot tools at gmail dot com
2010-09-15 4:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-04 13:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from hjl dot tools at gmail dot com 2010-06-04 13:56 -------
(In reply to comment #3)
> Yes, reassoc linearizes instead of building a tree (saves one (or was it two?)
> registers at best).
>
Should we always build a tree? It may increase register pressure.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
` (3 preceding siblings ...)
2010-06-04 13:57 ` hjl dot tools at gmail dot com
@ 2010-06-04 14:40 ` hjl dot tools at gmail dot com
2010-09-15 4:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-04 14:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2010-06-04 14:40 -------
tree-ssa-reassoc.c has
2. Left linearization of the expression trees, so that (A+B)+(C+D)
becomes (((A+B)+C)+D), which is easier for us to rewrite later.
During linearization, we place the operands of the binary
expressions into a vector of operand_entry_t
I think this may always generate slower codes. We may not want to
use much more registers. We can limit us to 2 temporaries.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/44382] Slow integer multiply
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
` (4 preceding siblings ...)
2010-06-04 14:40 ` hjl dot tools at gmail dot com
@ 2010-09-15 4:29 ` hjl dot tools at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-09-15 4:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from hjl dot tools at gmail dot com 2010-09-15 04:29 -------
*** Bug 45671 has been marked as a duplicate of this bug. ***
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pthaugen at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44382
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-09-15 4:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-02 15:04 [Bug middle-end/44382] New: Slow integer multiply hjl dot tools at gmail dot com
2010-06-02 15:15 ` [Bug middle-end/44382] " rguenth at gcc dot gnu dot org
2010-06-04 13:08 ` hjl dot tools at gmail dot com
2010-06-04 13:21 ` rguenth at gcc dot gnu dot org
2010-06-04 13:57 ` hjl dot tools at gmail dot com
2010-06-04 14:40 ` hjl dot tools at gmail dot com
2010-09-15 4:29 ` 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).