public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect.
@ 2023-08-04 21:01 cassio.neri at gmail dot com
  2023-08-04 21:02 ` [Bug middle-end/110906] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: cassio.neri at gmail dot com @ 2023-08-04 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110906
           Summary: __attribute__((optimize("no-math-errno"))) has no
                    effect.
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cassio.neri at gmail dot com
  Target Milestone: ---

Consider this C++ code compiled with -O3:

double g(double x) {
  return std::sqrt(x);
}

Usually this does call the library function std::sqrt because x might be
negative and errno needs to be set accordingly. Moreover, with -fno-math-errno
a single sqrtsd instruction is emitted. However, annotating g with

__attribute__((optimize("no-math-errno")))

has no effect. This attribute (and #pragma GCC optimize("no-math-errno") ) used
to work up to gcc 5.5.

https://godbolt.org/z/T1nb11bv5

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

* [Bug middle-end/110906] __attribute__((optimize("no-math-errno"))) has no effect.
  2023-08-04 21:01 [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect cassio.neri at gmail dot com
@ 2023-08-04 21:02 ` pinskia at gcc dot gnu.org
  2023-08-04 21:03 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-04 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
well std::sqrt is not annotated with no-math-errno after all ...

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

* [Bug middle-end/110906] __attribute__((optimize("no-math-errno"))) has no effect.
  2023-08-04 21:01 [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect cassio.neri at gmail dot com
  2023-08-04 21:02 ` [Bug middle-end/110906] " pinskia at gcc dot gnu.org
@ 2023-08-04 21:03 ` pinskia at gcc dot gnu.org
  2023-08-04 21:05 ` pinskia at gcc dot gnu.org
  2023-08-04 21:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-04 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55692
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55692&action=edit
Full testcase

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

* [Bug middle-end/110906] __attribute__((optimize("no-math-errno"))) has no effect.
  2023-08-04 21:01 [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect cassio.neri at gmail dot com
  2023-08-04 21:02 ` [Bug middle-end/110906] " pinskia at gcc dot gnu.org
  2023-08-04 21:03 ` pinskia at gcc dot gnu.org
@ 2023-08-04 21:05 ` pinskia at gcc dot gnu.org
  2023-08-04 21:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-04 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
But even:
```
__attribute__((optimize("no-math-errno")))
double g(double x) {
  return __builtin_sqrt(x);
}
```
Does not change here ...

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

* [Bug middle-end/110906] __attribute__((optimize("no-math-errno"))) has no effect.
  2023-08-04 21:01 [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect cassio.neri at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-04 21:05 ` pinskia at gcc dot gnu.org
@ 2023-08-04 21:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-04 21:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well "math-errno" has no effect if -fno-math-errno is supplied on the command
line either, well can produce incorrect code too.

Take:
```
__attribute__((optimize("math-errno")))
void g(double x) {
  __builtin_sqrt(x);
}
```
With `-O2`, a call happens but with `-O2 -fno-math-errno` does not happen. That
was true even in GCC 5.

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

end of thread, other threads:[~2023-08-04 21:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 21:01 [Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect cassio.neri at gmail dot com
2023-08-04 21:02 ` [Bug middle-end/110906] " pinskia at gcc dot gnu.org
2023-08-04 21:03 ` pinskia at gcc dot gnu.org
2023-08-04 21:05 ` pinskia at gcc dot gnu.org
2023-08-04 21:15 ` 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).