public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107137] New: (unsigned)-(int)(bool_var) should be optimized to -(unsigned)bool_var
@ 2022-10-03 19:40 pinskia at gcc dot gnu.org
  2022-10-06 10:02 ` [Bug tree-optimization/107137] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-03 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107137
           Summary: (unsigned)-(int)(bool_var) should be optimized to
                    -(unsigned)bool_var
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
unsigned f(_Bool a)
{
  int t = a;
  t = -t;
  return t;
}
```

Currently we get:
```
  t_2 = (int) a_1(D);
  t_3 = -t_2;
  _4 = (unsigned int) t_3;
```

But we can do better than that with just:
```
  _ = (unsigned int) a_1(D);
  _4 = -_;
```
Noticed that while looking into
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131.

Note even bool_var could be an unsigned type or a type which whos size is
bigger than the outer type really.

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

end of thread, other threads:[~2023-09-05 21:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-03 19:40 [Bug tree-optimization/107137] New: (unsigned)-(int)(bool_var) should be optimized to -(unsigned)bool_var pinskia at gcc dot gnu.org
2022-10-06 10:02 ` [Bug tree-optimization/107137] " rguenth at gcc dot gnu.org
2022-11-26 20:45 ` pinskia at gcc dot gnu.org
2023-08-31 18:34 ` pinskia at gcc dot gnu.org
2023-09-01  2:27 ` pinskia at gcc dot gnu.org
2023-09-01 16:26 ` pinskia at gcc dot gnu.org
2023-09-02  7:01 ` pinskia at gcc dot gnu.org
2023-09-05 21:16 ` cvs-commit at gcc dot gnu.org
2023-09-05 21: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).