public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109414] New: RISC-V: unnecessary sext.w in rv64
@ 2023-04-05  5:20 sinan.lin at linux dot alibaba.com
  2023-04-05  5:25 ` [Bug target/109414] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: sinan.lin at linux dot alibaba.com @ 2023-04-05  5:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109414
           Summary: RISC-V: unnecessary sext.w in rv64
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sinan.lin at linux dot alibaba.com
  Target Milestone: ---

I recently encountered several suboptimal cases with unnecessary sext.w in
not/and/xor/or in rv64i.

e.g.
```
int xor_2 (int x, int n) {
        return (x + 1) ^ n;
}

int not_2 (int x, int n) {
        return ~(x + n);
}
```


gcc:
```
xor_2:
        addiw   a0,a0,1
        xor     a0,a1,a0
        sext.w  a0,a0
        ret
not_2:
        addw    a0,a0,a1
        not     a0,a0
        sext.w  a0,a0
        ret
```

clang:
```
xor_2:
        addw    a0, a0, a1
        xor     a0, a0, a1
        ret
not_2:
        addw    a0, a0, a1
        not     a0, a0
        ret
```

This case looks a bit similar to
https://gcc.gnu.org/bugzilla//show_bug.cgi?id=106585 , where the X iterator is
used in insn pattern.

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

end of thread, other threads:[~2023-10-07 20:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05  5:20 [Bug target/109414] New: RISC-V: unnecessary sext.w in rv64 sinan.lin at linux dot alibaba.com
2023-04-05  5:25 ` [Bug target/109414] " pinskia at gcc dot gnu.org
2023-04-05  5:30 ` sinan.lin at linux dot alibaba.com
2023-04-05  5:32 ` pinskia at gcc dot gnu.org
2023-04-05  5:41 ` sinan.lin at linux dot alibaba.com
2023-10-07 20:39 ` law 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).