[clang] [clang] Add builtins for `add` with `nuw` and/or `nsw` (PR #130354)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 10 10:25:16 PDT 2025


================
@@ -5037,6 +5037,66 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> {
   let Prototype = "void(...)";
 }
 
+class SNUWTemplate :
+  Template<["int",      "long int",  "long long int"],
+           ["_nuw",     "l_nuw",     "ll_nuw"]>;
----------------
macurtis-amd wrote:

The intent is to map directly to llvm IR in order to give library writers full control of the generated `add` instruction.

So IMO deviating from the IR terminology would only add confusion.

Similarly, I think making assumptions or restrictions about when `nuw` and `nsw` are applicable might frustrate users who, for whatever reason, just want clang to generate some specific `add` instruction.

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


More information about the cfe-commits mailing list