Index: llvm/docs/LangRef.rst =================================================================== --- llvm/docs/LangRef.rst +++ llvm/docs/LangRef.rst @@ -2102,6 +2102,51 @@ generated code. For more details, see :ref:`GC Transitions `. +.. _assume_opbundles: + +Assume Operand Bundles +^^^^^^^^^^^^^^^^^^^^^^ + +Operand bundles on an :ref:`llvm.assume ` allows representing +assumptions that an attribute holds for a certain value at a certain position. +This allows representing assumptions that are either hard or not possible to +represent via a boolean check. + +* The tag of the operand bundle is the attribute that can be assumed to hold. +* The first argument if present is the value for which the attribute hold. +* The Second argument if present is an argument of the attribute. + +If there is no arguments the attribute is a property of the path + +For example: + +.. code-block:: llvm + + call void @llvm.assume(i1 true) ["align"(i32* %val, i32 8)] + +allows the optimizer to assume that ``%val`` has an alignment of at least 8 +at this point + +.. code-block:: llvm + + call void @llvm.assume(i1 true) ["cold"()] + +allows the optimizer to assume that the path is cold. + +If the provided guarantee is incorrect the behavior is undefined. + +Even if the property can be represented as a boolean property like ``nonnull``. +Using operand bundles to express the property still have benefits: + +* Attributes that can be expressed via operand bundles are directly the + property that the optimizer uses and cares about. So the optimizer doesn't + need to deduce the property from an arbitrary expression. The optimizer may + not have every canonicalizations to deduce the property from any arbitrary + expressions that check the property. +* Expressing the property using operand bundles make detecting that the value + is used in an :ref:`llvm.assume ` easier. Which can minimize the + impact of adding a use to the value. + .. _moduleasm: Module-Level Inline Assembly @@ -17532,10 +17577,14 @@ condition is true. This information can then be used in simplifying other parts of the code. +For operand bundles on an ``llvm.assume`` see +:ref:`assume operand bundles `. + Arguments: """""""""" -The condition which the optimizer may assume is always true. +The argument of the call is the condition which the optimizer may assume is +always true. Semantics: """"""""""