[llvm] [IR][RFC] Add @llvm.mask.beforefirst intrinsic (PR #203874)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 02:42:58 PDT 2026


https://github.com/fhahn commented:

> My point being that if we have a specific instruction with a specific cost in mind we want to emit in the vectorizer, I think it's better to have a dedicated intrinsic for it rather than spending extra effort trying to expand + recombine it.

Right, that is something that would be good to agree on either way. Another class of examples are various in-loop reductions, for which we do not have intrinsics, but have particular target instructions in mind when we generate IR. The current infrastructure we have (expression recipes, TTI hook) seems to give OK results. If we agree that intrinsics are the way to go, then those operations may also need revisiting for consistency.

> Ping for more discussion. I've put up a PR to show how the loop vectorizer would use it in #212717. It also shows how we get more accurate costing by sinking the `llvm.experimental.cttz.elts` to the middle block, since in an early exit loop it has multiple users, despite one of the users folding it into `brkb` on SVE.

Did you ever share this on discourse? If not, I think this would benefit from extra visibility beyond the people tagged the PR.

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


More information about the llvm-commits mailing list