[clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 13:22:15 PST 2024


efriedma-quic wrote:

> > llvm.trunc is currently marked IntrNoMem in Intrinsics.td; you'll need to update that if you want it to read/modify FP state. (Trying to override the default by sticking attributes on top doesn't work properly, as far as I know.)

> This this the key point in this solution, - we want to use the same intrinsic both in default and non-default environment. All properties necessary for non-default case will be attached to the call site. If something prevents this plan, we should evaluate it.

IntrNoMem gets translated to readnone, i.e. does not access any memory, including FP state.  If the intrinsic can in fact read/modify FP state in some cases, we have to remove that from the intrinsic.

There are basically two ways we can go from there.  One, we can just make the frontend and/or transforms add a readnone marking to callsites that can't actually access FP state (i.e. calls in non-strictfp functions).  Two, we can add a "readnone_fp_intrinsic" attribute, which would mean the intrinsic is readnone unless there's an operand bundle indicating otherwise.

I think the first way composes more cleanly with our general approach to memory effects.

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


More information about the cfe-commits mailing list