diff options
author | Florian Hahn <flo@fhahn.com> | 2025-09-05 15:51:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-05 14:51:54 +0000 |
commit | c8d065bf914d7c8feb06aa7978fe43b2a800b17f (patch) | |
tree | 1d6191391520ea0576211c4d7fe52ce3d7f3264b /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | ef1539c1d4e205b05bd8662c9d4e90382d2381a5 (diff) | |
download | llvm-c8d065bf914d7c8feb06aa7978fe43b2a800b17f.zip llvm-c8d065bf914d7c8feb06aa7978fe43b2a800b17f.tar.gz llvm-c8d065bf914d7c8feb06aa7978fe43b2a800b17f.tar.bz2 |
[Clang] Allow non-constant sizes for __builtin_assume_dereferenceable. (#156929)
Update Clang's __builtin_assume_dereferenceable to support non-constant
lengths. The corresponding assume bundle has been updated to support
non-constant sizes in cad62df49a7.
The current docs for the builtin don't mention the constant requirement
for the size argument, so don't need to be updated:
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-assume-dereferenceable
A number of patches landed recently to make the optimizer make better
use of the dereferenceable assumptions, and once
https://github.com/llvm/llvm-project/pull/156730 lands, it can be used
to vectorize some early-exit loops, for example std::find with
std::vector::iterator: https://godbolt.org/z/qo58PKG37
```
#include <algorithm>
#include <cstddef>
#include <vector>
auto find(std::vector<short>::iterator first, short s, unsigned size) {
auto Addr = __builtin_assume_aligned(std::to_address(first), 2);
__builtin_assume_dereferenceable(std::to_address(first), size * sizeof(short));
return std::find(first, first + size, s);
}
```
PR: https://github.com/llvm/llvm-project/pull/156929
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
0 files changed, 0 insertions, 0 deletions