public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-18589-5724@http.gcc.gnu.org/bugzilla/>]
* [Bug target/18589] New: could optimize FP multiplies better
@ 2004-11-21  9:28 debian-gcc at lists dot debian dot org
  2005-01-12  6:50 ` [Bug tree-optimization/18589] " pinskia at gcc dot gnu dot org
  2005-07-05 19:37 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 9+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-11-21  9:28 UTC (permalink / raw)
  To: gcc-bugs

[forwarded from http://bugs.debian.org/268115]

  Matthias

The bug submitter writes:


compiling this function:
double baz(double foo, double bar)
{
   return foo*foo*foo*foo*bar*bar*bar*bar;
}

 on amd64 with -O6 -ffast-math, gcc emits this code:

foo.o:     file format elf64-x86-64

Disassembly of section .text:

... (some similar functions that I was messing around with) ...
0000000000000050 <ddbar>:
  50:	f2 0f 59 c0          	mulsd  %xmm0,%xmm0
  54:	f2 0f 59 c0          	mulsd  %xmm0,%xmm0
  58:	f2 0f 59 c1          	mulsd  %xmm1,%xmm0
  5c:	f2 0f 59 c1          	mulsd  %xmm1,%xmm0
  60:	f2 0f 59 c1          	mulsd  %xmm1,%xmm0
  64:	f2 0f 59 c1          	mulsd  %xmm1,%xmm0
  68:	c3                   	retq   


 So, it notices that it can do foo*foo*foo*foo with two mulsd instructions,
but it misses the same optimization for bar*bar*bar*bar.  It would save one
FP multiply overall to do:
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm1, %xmm0
retq
 Also, the two non-dependent muls could run in parallel.
 
 Without -ffast-math, of course, gcc can't take advantage of the laws of
arithmetic like that and has to do all the multiplies the straightforward
way.

-- 
           Summary: could optimize FP multiplies better
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: amd64-linux
  GCC host triplet: amd64-linux
GCC target triplet: amd64-linux


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


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

end of thread, other threads:[~2012-04-12 16:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-18589-4@http.gcc.gnu.org/bugzilla/>
2012-01-05 23:07 ` [Bug tree-optimization/18589] could optimize FP multiplies better pinskia at gcc dot gnu.org
2012-01-09 12:21 ` rguenth at gcc dot gnu.org
2012-01-09 13:09 ` wschmidt at gcc dot gnu.org
2012-01-13 22:37 ` wschmidt at gcc dot gnu.org
2012-04-12 16:15 ` wschmidt at gcc dot gnu.org
2012-04-12 16:18 ` wschmidt at gcc dot gnu.org
     [not found] <bug-18589-5724@http.gcc.gnu.org/bugzilla/>
2006-03-05 17:43 ` pinskia at gcc dot gnu dot org
2004-11-21  9:28 [Bug target/18589] New: " debian-gcc at lists dot debian dot org
2005-01-12  6:50 ` [Bug tree-optimization/18589] " pinskia at gcc dot gnu dot org
2005-07-05 19:37 ` pinskia at gcc dot gnu dot org

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