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

--- Comment #1 from Liu Hao <lh_mouse at 126 dot com> ---
FWIW, it can still be improved when the constant is something other than 2.

For example:

```
bool mul_8_and_check(unsigned *dst, unsigned src){
    return __builtin_mul_overflow(src, 8, dst);
}
```

can be rewritten as:

bool mul_8_and_check(unsigned *dst, unsigned src){
    unsigned res = src << 3;
    *dst = res;
    return (res >> 3) != src; // The result will have been truncated if
                              // dividing the result by 8 does not yield
                              // the original value.
}
```

Reply via email to