public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102224] New: Incorrect compile on `x * copysign(1.0, x)`
@ 2021-09-07  2:56 gabravier at gmail dot com
  2021-09-07  2:58 ` [Bug tree-optimization/102224] " gabravier at gmail dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: gabravier at gmail dot com @ 2021-09-07  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102224
           Summary: Incorrect compile on `x * copysign(1.0, x)`
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

float f(float x, float y)
{
    return x * copysignf(1.0f, x);
}

On latest trunk with -O3 on x86, this compiles to:

f(float):
  andps xmm0, XMMWORD PTR .LC0[rip]
  xorps xmm0, xmm0
  ret
.LC0:
  .long -2147483648
  .long 0
  .long 0
  .long 0

This is likely because the XOR_SIGN pattern emitted by
convert_expand_mult_copysign fails to check that x and y are not the same
(note: it can be optimized to ABS_EXPR in that case).

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

end of thread, other threads:[~2022-05-11  6:36 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07  2:56 [Bug tree-optimization/102224] New: Incorrect compile on `x * copysign(1.0, x)` gabravier at gmail dot com
2021-09-07  2:58 ` [Bug tree-optimization/102224] " gabravier at gmail dot com
2021-09-07  2:59 ` gabravier at gmail dot com
2021-09-07  3:01 ` gabravier at gmail dot com
2021-09-07  3:04 ` [Bug target/102224] " pinskia at gcc dot gnu.org
2021-09-07  3:06 ` [Bug target/102224] [12 regession] wrong code for " pinskia at gcc dot gnu.org
2021-09-07  3:07 ` gabravier at gmail dot com
2021-09-07  3:18 ` [Bug target/102224] [9/10/11/12 " gabravier at gmail dot com
2021-09-07  3:25 ` gabravier at gmail dot com
2021-09-07  6:37 ` rguenth at gcc dot gnu.org
2021-09-07  9:33 ` [Bug target/102224] [9/10/11/12 regession] wrong code for `x * copysign(1.0, x)` since r9-5298-g33142cf9cf82aa1f marxin at gcc dot gnu.org
2021-09-07  9:51 ` jakub at gcc dot gnu.org
2021-09-07 11:25 ` jakub at gcc dot gnu.org
2021-09-07 18:53 ` pinskia at gcc dot gnu.org
2021-09-08  9:26 ` cvs-commit at gcc dot gnu.org
2021-09-08 10:08 ` [Bug target/102224] [9/10/11 " jakub at gcc dot gnu.org
2021-09-08 18:02 ` cvs-commit at gcc dot gnu.org
2021-09-08 18:03 ` [Bug target/102224] [9/10 " jakub at gcc dot gnu.org
2022-05-10  8:20 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:22 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub 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).