public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112104] New: loop of ^1 should just be reduced to ^(n&1)
@ 2023-10-27  3:47 pinskia at gcc dot gnu.org
  2023-10-27  4:04 ` [Bug tree-optimization/112104] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  3:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112104
           Summary: loop of ^1 should just be reduced to ^(n&1)
           Product: gcc
           Version: 14.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:
```
int
foo(long n3) {
  int j = 0;
  for(int i=0; i<n3; i++)
    j=j^1;
  return j;
}

int
foo1(long n3) {
  int j = 0;
  if (n3>=0)
    j = j ^ (n3&1);
  return j;
}
```

We should figure out that j as the result is just alternating between 0 and 1
(VRP figures that that is the range) in SCCP pattern matching.

I Noticed this while looking into PR 111972

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

end of thread, other threads:[~2023-11-15  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-27  3:47 [Bug tree-optimization/112104] New: loop of ^1 should just be reduced to ^(n&1) pinskia at gcc dot gnu.org
2023-10-27  4:04 ` [Bug tree-optimization/112104] " pinskia at gcc dot gnu.org
2023-10-27 13:08 ` rguenth at gcc dot gnu.org
2023-10-30  6:34 ` crazylht at gmail dot com
2023-11-14 17:01 ` pinskia at gcc dot gnu.org
2023-11-14 23:59 ` crazylht at gmail dot com
2023-11-15  0:00 ` pinskia at gcc dot gnu.org
2023-11-15  0:00 ` 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).