[llvm] [IR] Add initial support for the byte type (PR #178666)

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 02:41:32 PST 2026


================
@@ -13017,6 +13061,67 @@ Example:
       %Z = bitcast <2 x i32> %V to i64; ; yields i64: %V (depends on endianness)
       %Z = bitcast <2 x i32*> %V to <2 x i64*> ; yields <2 x i64*>
 
+.. _i_bytecast:
+
+'``bytecast .. to``' Instruction
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+    <result> = bytecast <ty> <value> to <ty2>             ; yields ty2
+
+Overview:
+"""""""""
+
+The '``bytecast``' instruction converts ``value``, of the byte type, to type
+``ty2`` performing type punning.
+
+Arguments:
+""""""""""
+
+The '``bytecast``' instruction takes a value to cast, which must be of the
+:ref:`byte type <t_byte>`, and a type to cast it to, which must be a
+non-aggregate :ref:`first class <t_firstclass>` type. The bit sizes of ``value``
+and the destination type, ``ty2``, must be identical. This instruction supports
+conversions from vectors of bytes to vector of other types (as long as they
+have the same size).
+
+Semantics:
+""""""""""
+
+The '``bytecast``' instruction converts the ``value`` of the :ref:`byte type
+<t_byte>` to type ``ty2``. If ``value`` contains at least one ``poison`` bit,
+the cast result is ``poison``. Otherwise, if ``value`` is any mix of
----------------
RalfJung wrote:

Typically for poison we treated it as maximally poisonous, e.g. even a bitwise and of poison with 0 produces poison. So it would be an odd departure from that precedent to try and do something more fine-grained here.

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


More information about the llvm-commits mailing list