public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/44134] Unneeded +0.0 for c = 0.0 ; c = c+ a*b
Date: Fri, 14 May 2010 13:10:00 -0000	[thread overview]
Message-ID: <20100514131034.24745.qmail@sourceware.org> (raw)
In-Reply-To: <bug-44134-10391@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from pinskia at gmail dot com  2010-05-14 13:10 -------
Subject: Re:   New: Unneeded +0.0 for c = 0.0 ; c = c+ a*b



Sent from my iPhone

On May 14, 2010, at 2:18 AM, "tkoenig at gcc dot gnu dot org"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

> This code leads to the adding of 0.0, which is a nop.  Any
> signalling should have been done previously.

It is not signalling that matters here but signed zero. 0.0 + -0.0 ==  
0.0. So without the 0.0 +, you can get a negative zero.


>
> ig25@linux-fd1f:/tmp> cat mult.f90
> subroutine foo(a,b,c)
>  real, intent(in) :: a,b
>  real, intent(out) :: c
>  c = 0.0
>  c = c + a*b
> end subroutine foo
> ig25@linux-fd1f:/tmp> gfortran -O3 -fdump-tree-optimized -S mult.f90
> ig25@linux-fd1f:/tmp> cat mult.f90.142t.optimized
>
> ;; Function foo (foo_)
>
> foo (real(kind=4) & restrict a, real(kind=4) & restrict b, real 
> (kind=4) &
> restrict c)
> {
>  real(kind=4) D.1542;
>  real(kind=4) D.1541;
>  real(kind=4) D.1540;
>  real(kind=4) D.1539;
>
> <bb 2>:
>  D.1539_4 = *a_3(D);
>  D.1540_6 = *b_5(D);
>  D.1541_7 = D.1539_4 * D.1540_6;
>  D.1542_8 = D.1541_7 + 0.0;
>  *c_1(D) = D.1542_8;
>  return;
>
> }
>
> ig25@linux-fd1f:/tmp> cat mult.s
>        .file   "mult.f90"
>        .text
>        .p2align 4,,15
> .globl foo_
>        .type   foo_, @function
> foo_:
> .LFB0:
>        movss   (%rdi), %xmm0
>        mulss   (%rsi), %xmm0
>        addss   .LC0(%rip), %xmm0
>        movss   %xmm0, (%rdx)
>        ret
> .LFE0:
>        .size   foo_, .-foo_
>        .section        .rodata.cst4,"aM",@progbits,4
>        .align 4
> .LC0:
>        .long   0
>        .section        .eh_frame,"a",@progbits
> .Lframe1:
>        .long   .LECIE1-.LSCIE1
> .LSCIE1:
>        .long   0
>        .byte   0x1
>        .string "zR"
>        .uleb128 0x1
>        .sleb128 -8
>        .byte   0x10
>        .uleb128 0x1
>        .byte   0x3
>        .byte   0xc
>        .uleb128 0x7
>        .uleb128 0x8
>        .byte   0x90
>        .uleb128 0x1
>        .align 8
> .LECIE1:
> .LSFDE1:
>        .long   .LEFDE1-.LASFDE1
> .LASFDE1:
>        .long   .LASFDE1-.Lframe1
>        .long   .LFB0
>        .long   .LFE0-.LFB0
>        .uleb128 0
>        .align 8
> .LEFDE1:
>        .ident  "GCC: (GNU) 4.6.0 20100513 (experimental)"
>        .section        .note.GNU-stack,"",@progbits
>
>
> -- 
>           Summary: Unneeded +0.0 for c = 0.0 ; c = c+ a*b
>           Product: gcc
>           Version: 4.6.0
>            Status: UNCONFIRMED
>          Keywords: missed-optimization
>          Severity: enhancement
>          Priority: P3
>         Component: middle-end
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: tkoenig at gcc dot gnu dot org
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44134
>


-- 


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


  parent reply	other threads:[~2010-05-14 13:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14  9:19 [Bug middle-end/44134] New: " tkoenig at gcc dot gnu dot org
2010-05-14 12:20 ` [Bug middle-end/44134] " rguenth at gcc dot gnu dot org
2010-05-14 13:10 ` pinskia at gmail dot com [this message]
2010-05-14 13:10 ` [Bug middle-end/44134] New: " Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100514131034.24745.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).