public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/116826] New: Optimise log (1.0 / x) into -log (x)
@ 2024-09-24  8:14 ktkachov at gcc dot gnu.org
  2024-09-24  9:56 ` [Bug tree-optimization/116826] " jschmitz at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2024-09-24  8:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116826

            Bug ID: 116826
           Summary: Optimise log (1.0 / x) into -log (x)
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

float
foo (float a)
{
  return __builtin_logf (1.0f / a);
}

We can avoid the division by folding it into -__builtin_logf (a);
under the usual -funsafe-math-optimizations group for all the various standard
logs.
More generally, log (CST / a) could be folded into log (CST) - log (a).

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

* [Bug tree-optimization/116826] Optimise log (1.0 / x) into -log (x)
  2024-09-24  8:14 [Bug tree-optimization/116826] New: Optimise log (1.0 / x) into -log (x) ktkachov at gcc dot gnu.org
@ 2024-09-24  9:56 ` jschmitz at gcc dot gnu.org
  2024-09-24 18:13 ` pinskia at gcc dot gnu.org
  2024-09-25  6:45 ` ktkachov at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jschmitz at gcc dot gnu.org @ 2024-09-24  9:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116826

Jennifer Schmitz <jschmitz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-09-24
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
                 CC|                            |jschmitz at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jschmitz at gcc dot gnu.org

--- Comment #1 from Jennifer Schmitz <jschmitz at gcc dot gnu.org> ---
.

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

* [Bug tree-optimization/116826] Optimise log (1.0 / x) into -log (x)
  2024-09-24  8:14 [Bug tree-optimization/116826] New: Optimise log (1.0 / x) into -log (x) ktkachov at gcc dot gnu.org
  2024-09-24  9:56 ` [Bug tree-optimization/116826] " jschmitz at gcc dot gnu.org
@ 2024-09-24 18:13 ` pinskia at gcc dot gnu.org
  2024-09-25  6:45 ` ktkachov at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-24 18:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116826

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note PR 86710 lists the opposite (except without being a CST for the division).

Just like PR 86710, this applies for log, log10 and log2 too (and the type
variants too).

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

* [Bug tree-optimization/116826] Optimise log (1.0 / x) into -log (x)
  2024-09-24  8:14 [Bug tree-optimization/116826] New: Optimise log (1.0 / x) into -log (x) ktkachov at gcc dot gnu.org
  2024-09-24  9:56 ` [Bug tree-optimization/116826] " jschmitz at gcc dot gnu.org
  2024-09-24 18:13 ` pinskia at gcc dot gnu.org
@ 2024-09-25  6:45 ` ktkachov at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2024-09-25  6:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116826

--- Comment #3 from ktkachov at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #2)
> Note PR 86710 lists the opposite (except without being a CST for the
> division).
> 
> Just like PR 86710, this applies for log, log10 and log2 too (and the type
> variants too).

Thanks for the reference. Yeah, splitting up one log call to two log calls is
not a good idea for variable arguments, but when we can calculate the log (CST)
at compile-time it should be a win.

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

end of thread, other threads:[~2024-09-25  6:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-24  8:14 [Bug tree-optimization/116826] New: Optimise log (1.0 / x) into -log (x) ktkachov at gcc dot gnu.org
2024-09-24  9:56 ` [Bug tree-optimization/116826] " jschmitz at gcc dot gnu.org
2024-09-24 18:13 ` pinskia at gcc dot gnu.org
2024-09-25  6:45 ` ktkachov 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).