public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) @ 2013-01-09 7:46 vincenzo.innocente at cern dot ch 2013-01-09 8:59 ` [Bug tree-optimization/55912] " glisse at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: vincenzo.innocente at cern dot ch @ 2013-01-09 7:46 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55912 Bug #: 55912 Summary: missing optimization of x/x and x/std::abs(x) Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincenzo.innocente@cern.ch in the following examples I'm quite surprised that only (x/x)is optimized to "!". With Ofast (and even more with -mrecip) I would have expected that commutativity of multiplication to be used at least to optimized x*a/x Optimizing x/x and x/std::abs(x) would be beneficial with -mrecip to amortize a trivial loss of precision. cat one.cc;c++ -Ofast -S one.cc -msse4.2; cat one.s #include<cmath> int one1(float a, float x) { return x*a/x; } #include<cmath> int one2(float a, float x) { return a*(x/x); } int sign1(float a, float x) { return x*a/std::abs(x); } int sign2(float a, float x) { return a*(x/std::abs(x)); } .text .align 4,0x90 .globl __Z4one1ff __Z4one1ff: LFB86: mulss %xmm1, %xmm0 divss %xmm1, %xmm0 cvttss2si %xmm0, %eax ret LFE86: .align 4,0x90 .globl __Z4one2ff __Z4one2ff: LFB87: cvttss2si %xmm0, %eax ret LFE87: .align 4,0x90 .globl __Z5sign1ff __Z5sign1ff: LFB88: mulss %xmm1, %xmm0 movss LC0(%rip), %xmm2 andps %xmm2, %xmm1 divss %xmm1, %xmm0 cvttss2si %xmm0, %eax ret LFE88: .align 4,0x90 .globl __Z5sign2ff __Z5sign2ff: LFB89: movss LC0(%rip), %xmm2 andps %xmm1, %xmm2 divss %xmm2, %xmm1 mulss %xmm0, %xmm1 cvttss2si %xmm1, %eax ret ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/55912] missing optimization of x/x and x/std::abs(x) 2013-01-09 7:46 [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) vincenzo.innocente at cern dot ch @ 2013-01-09 8:59 ` glisse at gcc dot gnu.org 2013-01-09 9:27 ` rguenth at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: glisse at gcc dot gnu.org @ 2013-01-09 8:59 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55912 Marc Glisse <glisse at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |glisse at gcc dot gnu.org --- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> 2013-01-09 08:59:26 UTC --- Thanks. Hmm, what I was suggesting in the other bug (trivial code in fold-const.c) would probably only help for sign2, and only if you use fabsf instead of std::abs :-( ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/55912] missing optimization of x/x and x/std::abs(x) 2013-01-09 7:46 [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) vincenzo.innocente at cern dot ch 2013-01-09 8:59 ` [Bug tree-optimization/55912] " glisse at gcc dot gnu.org @ 2013-01-09 9:27 ` rguenth at gcc dot gnu.org 2013-10-12 18:35 ` glisse at gcc dot gnu.org 2021-08-10 19:06 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2013-01-09 9:27 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55912 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-01-09 Ever Confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-09 09:26:58 UTC --- Most of the math builtin folding needs to be re-done at GIMPLE level based on SSA form. Convenient places are either tree-ssa-forwprop.c or tree-ssa-math-opts.c (sincos pass which also does power series expansion now). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/55912] missing optimization of x/x and x/std::abs(x) 2013-01-09 7:46 [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) vincenzo.innocente at cern dot ch 2013-01-09 8:59 ` [Bug tree-optimization/55912] " glisse at gcc dot gnu.org 2013-01-09 9:27 ` rguenth at gcc dot gnu.org @ 2013-10-12 18:35 ` glisse at gcc dot gnu.org 2021-08-10 19:06 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: glisse at gcc dot gnu.org @ 2013-10-12 18:35 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55912 --- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to Richard Biener from comment #2) > Most of the math builtin folding needs to be re-done at GIMPLE level based > on SSA form. Convenient places are either tree-ssa-forwprop.c or > tree-ssa-math-opts.c (sincos pass which also does power series expansion > now). tree-ssa-reassoc.c seems like a natural place to optimize x*a/x, since it already handles x+a-x. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/55912] missing optimization of x/x and x/std::abs(x) 2013-01-09 7:46 [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) vincenzo.innocente at cern dot ch ` (2 preceding siblings ...) 2013-10-12 18:35 ` glisse at gcc dot gnu.org @ 2021-08-10 19:06 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-10 19:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55912 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Keywords| |missed-optimization ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-10 19:06 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-01-09 7:46 [Bug tree-optimization/55912] New: missing optimization of x/x and x/std::abs(x) vincenzo.innocente at cern dot ch 2013-01-09 8:59 ` [Bug tree-optimization/55912] " glisse at gcc dot gnu.org 2013-01-09 9:27 ` rguenth at gcc dot gnu.org 2013-10-12 18:35 ` glisse at gcc dot gnu.org 2021-08-10 19:06 ` pinskia at gcc dot gnu.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).