[llvm] [LLVM][CodeGen][SVE] Only use unpredicated bfloat instructions when all lanes are in use. (PR #168387)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 05:18:35 PST 2025
davemgreen wrote:
> While SVE support for exception safe floating point code generation is bare bones we try to ensure inactive lanes remain inert. I mistakenly broke this rule when adding support for SVE-B16B16 by lowering some bfloat operations of unpacked vectors to unpredicated instructions.
Hi - If this is specifically for a fadd node then the fp-exception flags are not observable outside of strict-fp and we assume cannot trap. Otherwise fp operations would have side-effects and not be speculatable. In order for fp exceptions to be observable you are required to use the strict-fp llvm.constrained.fadd intrinsics, which should turn into a STRICT_FADD ISD node.
There are details in https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics. Strictfp functions require a function attribute. From target predicated llvm.aarch64.sve.fadd intrinsics my understanding is that it will depend on the function and should correctly preserve/honour fp exceptions and rounding modes in strict-fp, but don't need to outside of it.
So if this is just for fadd I think the code was fine and it is OK to do whatever in the off lanes, including setting fp exception bits. Some of this might change, there are discussion on discourse, but my understanding is the basics wouldn't change (there are still a difference between ISD::FADD and ISD::STRICT_FADD and fp exceptions by default are not observable).
https://github.com/llvm/llvm-project/pull/168387
More information about the llvm-commits
mailing list