[llvm] [LAA] Improve the output remark for LoopVectorize (PR #65832)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 22:03:49 PDT 2023
https://github.com/vfdff updated https://github.com/llvm/llvm-project/pull/65832:
>From 7765ab39e467af92c783551d12f9e3a5c8cffa2d Mon Sep 17 00:00:00 2001
From: Zhongyunde <zhongyunde at huawei.com>
Date: Sat, 9 Sep 2023 12:59:33 +0800
Subject: [PATCH] [LAA] Improve the output remark for LoopVectorize
Don't report 'Use #pragma loop distribute(enable) to allow loop
distribution' when we already add #pragma clang loop distribute(enable)
Fixes https://github.com/llvm/llvm-project/issues/64637
---
llvm/lib/Analysis/LoopAccessAnalysis.cpp | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 4dd150492453f72..8a779ac9fb94f64 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2505,12 +2505,24 @@ void LoopAccessInfo::emitUnsafeDependenceRemark() {
LLVM_DEBUG(dbgs() << "LAA: unsafe dependent memory operations in loop\n");
// Emit remark for first unsafe dependence
+ bool HasForcedDistribution = false;
+ std::optional<const MDOperand *> Value =
+ findStringMetadataForLoop(TheLoop, "llvm.loop.distribute.enable");
+ if (Value) {
+ const MDOperand *Op = *Value;
+ assert(Op && mdconst::hasa<ConstantInt>(*Op) && "invalid metadata");
+ HasForcedDistribution = mdconst::extract<ConstantInt>(*Op)->getZExtValue();
+ }
+
+ const std::string Info =
+ HasForcedDistribution
+ ? "unsafe dependent memory operations in loop."
+ : "unsafe dependent memory operations in loop. Use "
+ "#pragma loop distribute(enable) to allow loop distribution "
+ "to attempt to isolate the offending operations into a separate "
+ "loop";
OptimizationRemarkAnalysis &R =
- recordAnalysis("UnsafeDep", Dep.getDestination(*this))
- << "unsafe dependent memory operations in loop. Use "
- "#pragma loop distribute(enable) to allow loop distribution "
- "to attempt to isolate the offending operations into a separate "
- "loop";
+ recordAnalysis("UnsafeDep", Dep.getDestination(*this)) << Info;
switch (Dep.Type) {
case MemoryDepChecker::Dependence::NoDep:
More information about the llvm-commits
mailing list