diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2834,10 +2834,6 @@ // to avoid other parts using the current constant value for simpliication. auto &OMPInfoCache = static_cast(A.getInfoCache()); - // If we have disabled SPMD-ization, stop - if (DisableOpenMPOptSPMDization) - SPMDCompatibilityTracker.indicatePessimisticFixpoint(); - Function *Fn = getAnchorScope(); if (!OMPInfoCache.Kernels.count(Fn)) return; @@ -2976,6 +2972,9 @@ dyn_cast(KernelInitCB->getArgOperand(InitIsSPMDArgNo)); if (IsSPMDArg && !IsSPMDArg->isZero()) SPMDCompatibilityTracker.indicateOptimisticFixpoint(); + // This is a generic region but SPMDization is disabled so stop tracking. + else if (DisableOpenMPOptSPMDization) + SPMDCompatibilityTracker.indicatePessimisticFixpoint(); } /// Modify the IR based on the KernelInfoState as the fixpoint iteration is