[Mlir-commits] [mlir] [mlir] Added `Convergent` trait that matches LLVM's semantics (PR #152358)
Nikolay Panchenko
llvmlistbot at llvm.org
Thu Aug 7 06:59:42 PDT 2025
================
@@ -337,8 +337,12 @@ struct ReturnLike : public TraitBase<ConcreteType, ReturnLike> {
return success();
}
};
-} // namespace OpTrait
+// The Operation may not be made control-dependent on any additional values.
+// See https://llvm.org/docs/ConvergentOperations.html for more details.
+template <typename ConcreteType>
+struct Convergent : public TraitBase<ConcreteType, Convergent> {};
----------------
npanchen wrote:
the `convergent` property is only set on the intrinsic, not on arbitrary function that calls to that intrinsic. Since LLVM does not infer that property automatically, that can result to undesired optimization.
Just to highlight that JT works differently for the case I described above: https://godbolt.org/z/9T4d7MM58. To note, the IR there looks ok, but the problem I observed is similar, but just has more complex CF.
Also, the MLIR trait seems generally useful to prevent, say, loop multiversioning by trip count if loop contains such operation.
https://github.com/llvm/llvm-project/pull/152358
More information about the Mlir-commits
mailing list