missing shrink wrapping due to missing store sinking
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Take:
```
void f(int*);
void g(unsigned a, int b)
{
int t = a;
if (b) return;
f(&t);
}
```
This should allow for shrink wrapping. But currently does not. Because the store to t is not sunk past the conditional.
This is forwarded from https://gcc.gnu.org/PR125400 (GCC has the same issue). This is also reduced from this simple C++ code for C++98 with the GCC's trunk version of libstdc++v3:
```
#include
void push_back(std::vector& xs, unsigned char x) {
xs.push_back(x);
}
```
(The full case of this not shrink wrapping [for C++11/17/20/23] is https://github.com/llvm/llvm-project/issues/123120 ).
Contributor guide
Research direction
Start with the reduced C reproducer in the issue and trace how store sinking interacts with shrink wrapping around the conditional return. Compare the behavior with the linked GCC and LLVM cases; done means the store to t can move past the conditional so shrink wrapping is enabled, while the vector push_back reduction is also addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100