[Mlir-commits] [mlir] [MLIR][ArithToSPIRV] Guard NoSignedWrap/NoUnsignedWrap behind extension/version check (PR #189061)
Dmitry Sidorov
llvmlistbot at llvm.org
Wed May 6 14:48:42 PDT 2026
MrSidims wrote:
Incidentally found this PR. Since I have some experience in SPIR-V (though not much experience in MLIR toolchains, so can't tell if my suggestion is applicable) here is what can be done:
(prerequisite A): Have an option to control, which SPIR-V version should generator target;
(prerequisite B): Have an option to control, which extensions are allowed.
1. Check if target SPIR-V version >= 1.4 - generate nowrap decorations without extensions;
2. If target SPIR-V version is < 1.4 - check if SPV_KHR_no_integer_wrap_decoration is enabled - if yes - emit nowrap decorations + extension string + extension capability;
3. If none applicable there are set of options:
3.1 do nothing - not ideal, we lose some semantics;
3.2 error out - not ideal, but fine in most of the cases;
3.3 do some expansion/emulation, `add nsw` is basically: `add`, `check` for overflow - if occurs `select` poison (well, since a concept of poison is just being added in SPIR-V - OpUndef should be also fine)
https://github.com/llvm/llvm-project/pull/189061
More information about the Mlir-commits
mailing list