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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note if the code was written as:
```
int f(int x)
{
    int t = (10000 * (x == 1));
    return 100 >> t;
}
```

We do change `100 >> t` to just `100` (starting in GCC 13).


What is happening in the original testcase is in the fold we are first
converting `(10000 * (x == 1))` into `x == 1 ? 10000 : 0` and then `100 >>
(10000 * (x == 1))` (and `100 >> (x == 1 ? 10000 : 0)`  into `x == 1 ? (100 >>
10000) : (100 >> 0)` and that gets converted into just `x == 1 ? 0 : 100`.

Maybe this is premature optimization these days.

Reply via email to