[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 24 04:28:07 PDT 2024


================
@@ -11318,6 +11321,14 @@ and converts the remaining bits to ``ty2``. Since the source size must
 be larger than the destination size, ``trunc`` cannot be a *no-op cast*.
 It will always truncate bits.
 
+``nuw`` and ``nsw`` stand for "No Unsigned Wrap" and "No Signed Wrap",
+respectively. If the ``nuw`` and/or ``nsw`` keywords are present, the
+result value of the ``trunc`` is a :ref:`poison value <poisonvalues>`.
----------------
nikic wrote:

This now reads as if the result is *always* a poison value. I'd drop this sentence and just have something like the following two:

> Is the nuw keyword is present, and any of the truncated bits are zero, the result is a poison value. If the nsw keyword is present, and any of the truncated bits are not the same as the top bit of the truncation result, the result is a poison value.

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


More information about the llvm-commits mailing list