[clang] [llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)

Shilei Tian via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 17 07:13:20 PDT 2026


shiltian wrote:

> Right, but I meant test with some options already fails because of some other `tablegen instruction-seletor` feature check with non-obvious cannot select. With early intrinsic feature check it fails gracefully. But in essence it is same `feature check` ? or am I misunderstanding something.

It depends on how the intrinsic is selected. If an intrinsic maps directly to an instruction guarded by a feature, then yes, it currently fails with a "cannot select" error. If the intrinsic requires more backend involvement, the behavior is less obvious.

Also, in our current intrinsic lowering implementation, feature checks are handled inconsistently. In some cases, we check whether a feature is required before emitting anything, but those checks are scattered across multiple places. Most of the time, we don't perform such checks at all.

What this PR does is essentially a feature check, but implemented in a different way. It catches these errors earlier and produces a clearer diagnostic instead of a generic "cannot select" error, which can mean many different things.

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


More information about the cfe-commits mailing list