public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/48092] New: associative property of sqrt Date: Sat, 12 Mar 2011 14:57:00 -0000 [thread overview] Message-ID: <bug-48092-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48092 Summary: associative property of sqrt Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincenzo.innocente@cern.ch Is there any reason why (with -Ofast or -ffast-math) associative properties of sqrt are not exploited as for instance those of division? examples division (ok) float div1(float a, float x, float y) { return a/x/y; 0: f3 0f 59 ca mulss %xmm2,%xmm1 4: f3 0f 5e c1 divss %xmm1,%xmm0 } sqrt float sqrt1(float a, float x, float y) { return a*std::sqrt(x)*std::sqrt(y); 10: f3 0f 51 d2 sqrtss %xmm2,%xmm2 14: f3 0f 51 c9 sqrtss %xmm1,%xmm1 18: f3 0f 59 ca mulss %xmm2,%xmm1 1c: f3 0f 59 c8 mulss %xmm0,%xmm1 } 20: 0f 28 c1 movaps %xmm1,%xmm0 and float rsqrt1(float a, float x, float y) { return a/std::sqrt(x)/std::sqrt(y); 30: f3 0f 51 c9 sqrtss %xmm1,%xmm1 34: f3 0f 51 d2 sqrtss %xmm2,%xmm2 38: f3 0f 59 d1 mulss %xmm1,%xmm2 3c: f3 0f 5e c2 divss %xmm2,%xmm0 } in this second case I would have at least expected the use of "rsqrtss" to take precedence above the associative property of "div" emitting the same code as below float rsqrt2(float a, float x, float y) { return a/sqrtf(x*y); 70: f3 0f 59 ca mulss %xmm2,%xmm1 74: f3 0f 52 d9 rsqrtss %xmm1,%xmm3 78: f3 0f 59 cb mulss %xmm3,%xmm1 7c: f3 0f 59 cb mulss %xmm3,%xmm1 80: f3 0f 59 1d 00 00 00 mulss 0(%rip),%xmm3 # 88 <rsqrt2(float, float, float)+0x18> 87: 00 84: R_X86_64_PC32 .LC1+0xfffffffffffffffc 88: f3 0f 58 0d 00 00 00 addss 0(%rip),%xmm1 # 90 <rsqrt2(float, float, float)+0x20> 8f: 00 8c: R_X86_64_PC32 .LC0+0xfffffffffffffffc 90: f3 0f 59 cb mulss %xmm3,%xmm1 94: f3 0f 59 c8 mulss %xmm0,%xmm1 } 98: 0f 28 c1 movaps %xmm1,%xmm0
next reply other threads:[~2011-03-12 14:57 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-03-12 14:57 vincenzo.innocente at cern dot ch [this message] 2011-08-05 8:17 ` [Bug rtl-optimization/48092] missing optimization (associative property of sqrt) vincenzo.innocente at cern dot ch 2011-08-05 8:35 ` [Bug tree-optimization/48092] associative property of builtins is not exploited on GIMPLE rguenth at gcc dot gnu.org 2011-09-08 10:14 ` vincenzo.innocente at cern dot ch 2011-09-08 11:59 ` rguenther at suse dot de 2021-07-21 2:46 ` pinskia at gcc dot gnu.org 2023-05-12 5:46 ` pinskia at gcc dot gnu.org
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=bug-48092-4@http.gcc.gnu.org/bugzilla/ \ --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: linkBe 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).