public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98303] New: [x86] Bad register allocation when reproducing assembly code
@ 2020-12-15 21:23 gabravier at gmail dot com
  2021-09-18 22:29 ` [Bug target/98303] cmov seems not to swap condition during RA pinskia at gcc dot gnu.org
  2021-09-19 23:16 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2020-12-15 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98303
           Summary: [x86] Bad register allocation when reproducing
                    assembly code
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f1(int n)
{
    while (n >= 64)
        n -= 64;

    return n;
}

On x86, with -O3, this generates :

f1(int):
  mov eax, edi
  and eax, 63
  cmp edi, 63
  cmovle eax, edi
  ret

This code :

int f2(int n)
{
    return (n <= 63) ? n : (n & 63);
}

which behaves equivalently, seems to result in poorer generated code :

f2(int):
  mov edx, edi
  mov eax, edi
  and edx, 63
  cmp edi, 63
  cmovg eax, edx
  ret

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

* [Bug target/98303] cmov seems not to swap condition during RA
  2020-12-15 21:23 [Bug target/98303] New: [x86] Bad register allocation when reproducing assembly code gabravier at gmail dot com
@ 2021-09-18 22:29 ` pinskia at gcc dot gnu.org
  2021-09-19 23:16 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18 22:29 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement
            Summary|[x86] Bad register          |cmov seems not to swap
                   |allocation when reproducing |condition during RA
                   |assembly code               |
   Last reconfirmed|                            |2021-09-18

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is the case where register allocator and cmov's (and 2 operands) don't get
along.

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

* [Bug target/98303] cmov seems not to swap condition during RA
  2020-12-15 21:23 [Bug target/98303] New: [x86] Bad register allocation when reproducing assembly code gabravier at gmail dot com
  2021-09-18 22:29 ` [Bug target/98303] cmov seems not to swap condition during RA pinskia at gcc dot gnu.org
@ 2021-09-19 23:16 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19 23:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 97968.

*** This bug has been marked as a duplicate of bug 97968 ***

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

end of thread, other threads:[~2021-09-19 23:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 21:23 [Bug target/98303] New: [x86] Bad register allocation when reproducing assembly code gabravier at gmail dot com
2021-09-18 22:29 ` [Bug target/98303] cmov seems not to swap condition during RA pinskia at gcc dot gnu.org
2021-09-19 23:16 ` 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).