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

            Bug ID: 126670
           Summary: missing detection of __builtin_bitreverse for loop
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 114527
  Target Milestone: ---

Take:
```
unsigned f1(unsigned a)
{
    unsigned x = 0;
    for(int i=0;i<8*sizeof(int);i++)
    {
        x = (x<<1) | (a&1);
        a >>= 1;
    }
    return x;
}
```

This should be recognized as __builtin_bitreverse32 (a).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114527
[Bug 114527] [meta-bug] missed sccp (final value) optimizations

Reply via email to