public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/105135] New: [11/12 Regression] Optimization regression for handrolled branchless assignment
@ 2022-04-02  8:53 andre.schackier at gmail dot com
  2022-04-04  7:17 ` [Bug middle-end/105135] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: andre.schackier at gmail dot com @ 2022-04-02  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105135
           Summary: [11/12 Regression] Optimization regression for
                    handrolled branchless assignment
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andre.schackier at gmail dot com
  Target Milestone: ---

Given the following source code [godbolt](https://godbolt.org/z/rrP3bqGW7):

```cpp
char to_lower_1(const char c) { return c + ((c >= 'A' && c <= 'Z') * 32); }

char to_lower_2(const char c) { return c + (((c >= 'A') & (c <= 'Z')) * 32); }

char to_lower_3(const char c) {
    if (c >= 'A' && c <= 'Z') {
        return c + 32;
    }
    return c;
}
```

compiling with `-O3`

produces the following assembly

```asm
to_lower_1(char):
        lea     eax, [rdi-65]
        cmp     al, 25
        setbe   al
        sal     eax, 5
        add     eax, edi
        ret
to_lower_2(char):
        lea     eax, [rdi-65]
        cmp     al, 25
        setbe   al
        sal     eax, 5
        add     eax, edi
        ret
to_lower_3(char):
        lea     edx, [rdi-65]
        lea     eax, [rdi+32]
        cmp     dl, 26
        cmovnb  eax, edi
        ret
```

Note that gcc-10.3 did produce the same assembly for all 3 functions while
gcc-11 and trunk do not.

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

end of thread, other threads:[~2023-05-29 10:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02  8:53 [Bug middle-end/105135] New: [11/12 Regression] Optimization regression for handrolled branchless assignment andre.schackier at gmail dot com
2022-04-04  7:17 ` [Bug middle-end/105135] " rguenth at gcc dot gnu.org
2022-04-04  9:47 ` [Bug middle-end/105135] [11/12 Regression] Optimization regression for handrolled branchless assignment since r11-4717-g3e190757fa332d32 marxin at gcc dot gnu.org
2022-04-04 11:49 ` jakub at gcc dot gnu.org
2022-04-21  7:51 ` rguenth at gcc dot gnu.org
2022-07-26 12:37 ` [Bug target/105135] [11/12/13 " rguenth at gcc dot gnu.org
2022-07-26 13:36 ` amonakov at gcc dot gnu.org
2023-03-11  5:29 ` pinskia at gcc dot gnu.org
2023-03-11  5:32 ` [Bug tree-optimization/105135] " pinskia at gcc dot gnu.org
2023-05-29 10:06 ` [Bug tree-optimization/105135] [11/12/13/14 " 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).