[Bug middle-end/126857] New: Redundant bit set after bit test came positive

uis9936 at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126857

            Bug ID: 126857
           Summary: Redundant bit set after bit test came positive
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: uis9936 at gmail dot com
  Target Milestone: ---

void g();
int f(int a, int b) {
    bool t = false;
    t = (a >> b) & 1;
    if(t) {
        a = a | (1 << b);
        g();
    }
    return a;
}

This came up during testing done for bug 122018. I guess this is middle-end
problem. IMO struct bitfields are better construct, but bitfields in integer is
more wide-spread pattern.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.