Issue 53102
Summary Missed optimization with `__attribute__((pure))`
Labels new issue
Assignees
Reporter OfekShilon
    ```c++
int somefunc(const int&) __attribute__((pure));
void nothing();

int f(int i) {
    i = somefunc(i);
    i++;
    nothing();
    i++;
    nothing();
    i++;
    return i;
}
```
The emitted code loads, increments, and stores `i` 3 times : https://godbolt.org/z/7YW7187s1
In gcc it doesn't: https://godbolt.org/z/Ye9aYn4MG
Also, if `somefunc` is made to return void, the optimization does kick in: https://godbolt.org/z/hsEdPThsf
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to