/*========================== begin_copyright_notice ============================ Copyright (C) 2025 Intel Corporation SPDX-License-Identifier: MIT ============================= end_copyright_notice ===========================*/ The reason for removal of below condition was that it took a very strict approach to the Convergent attribute, which caused missed optimization opportunities in cases where it was safe to do so. The decision is based on the discussion in LLVM RFC https://reviews.llvm.org/D90361?id=303195 This patch should be considered obsolete if LICM introduces a more advanced approach to the Convergent attribute in the future version of LLVM. --- diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 2865dece8..f879176b3 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1202,8 +1202,18 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, // inter-thread communication which results are implicitly affected by the // enclosing control flows. It is not safe to hoist or sink such operations // across control flow. - if (CI->isConvergent()) - return false; + + // The reason for removal of below condition was that it took a very strict + // approach to the Convergent attribute, which caused missed optimization + // opportunities in cases where it was safe to do so. + // The decision is based on the discussion in LLVM RFC + // https://reviews.llvm.org/D90361?id=303195 + // This patch should be considered obsolete if LICM introduces a more + // advanced approach to the Convergent attribute in the future version of + // LLVM. + + //if (CI->isConvergent()) + // return false; using namespace PatternMatch; if (match(CI, m_Intrinsic())) -- 2.43.0