[libcxx-commits] [libcxx] [libc++] Memoise `size()` in `vector::__assign_with_size` (PR #180288)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 10 04:03:34 PST 2026


philnik777 wrote:

> [@ldionne asked me to move this from #155330](https://github.com/llvm/llvm-project/pull/155330/changes#r2774544772) to simplify that diff, because he felt this would be a non-controversial change. This change [improves codegen and debuginfo](https://godbolt.org/z/6EdGf15za).
> 
> Do you have reservations about us splitting this from #155330, or are you just curious about why this is of interest?

I'd like to understand why and how this patch improves things, and whether there is a more general fix for the issue. In this case, we could add a `__builtin_assume_separate_storage(__begin_, this);` instead, which gives the optimizer the information to do the fold itself. I'm sure with this it will find more cases like the one here than if we do the optimization manually. I of course can't tell you whether we should do this, since assumes can block other optimizations, but I think we should at least look into it.

https://github.com/llvm/llvm-project/pull/180288


More information about the libcxx-commits mailing list