[PATCH] D59065: Add ptrmask intrinsic
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 11:53:42 PDT 2019
efriedma added a comment.
It might be simpler to describe the semantics in terms of GEP: e.g. `ptrmask(x)` is equivalent to `gep x, (ptrtoint(x)&mask)-ptrtoint(x)`. I think that has the same semantics as the description, but it might be easier to understand for a reader familiar with GEPs.
Actually, a frontend could emit that explicitly and get reasonable results in most cases, I think. For example, "char*a(char*p) { return p+(((long)p&-8)-(long)p); }" in C produces a single "andq" instruction at -O2. Granted, you probably wouldn't want to depend on that if you're compiling a language that depends on a lot of ptrmasks; it has inaccurate cost modeling, you might end up with extra operations if the sequence gets split into multiple blocks, and it produces low-quality code at -O0.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59065/new/
https://reviews.llvm.org/D59065
More information about the llvm-commits
mailing list