[llvm-branch-commits] [clang] [CIR] Replace nsw/nuw unit attrs with OverflowFlags BitEnum (PR #195618)
Andy Kaylor via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 5 13:05:43 PDT 2026
================
@@ -2426,19 +2430,21 @@ def CIR_AddOp : CIR_SaturatableBinaryOp<"add", CIR_AnyArithType> {
operands. Both operands and the result must have the same type.
For integer types, the optional `nsw` (no signed wrap) and `nuw` (no
- unsigned wrap) unit attributes indicate that the result is poison if signed
- or unsigned overflow occurs, respectively. The optional `sat` (saturated)
- attribute clamps the result to the type's representable range instead of
- wrapping. The `nsw`/`nuw` flags and `sat` are mutually exclusive.
-
+ unsigned wrap) overflow flags indicate that the result is poison if signed
+ or unsigned overflow occurs, respectively. Combined flags are written as
+ `nsw|nuw`. The optional `sat` (saturated) attribute clamps the result to
+ the type's representable range instead of wrapping. The `nsw`/`nuw` flags
+ and `sat` are mutually exclusive.
+
Example:
```
%0 = cir.add %a, %b : !s32i
%1 = cir.add nsw %a, %b : !s32i
%2 = cir.add nuw %a, %b : !u32i
- %3 = cir.add sat %a, %b : !s32i
- %4 = cir.add %a, %b : !cir.float
+ %3 = cir.add nsw|nuw %a, %b : !s32i
----------------
andykaylor wrote:
I don't like this representation. I'm used to seeing this as `nuw nsw` in LLVM IR, and having it represented otherwise in CIR feels jarring.
https://github.com/llvm/llvm-project/pull/195618
More information about the llvm-branch-commits
mailing list