[llvm] [AMDGPU] Do not preserve UniformityInfo (PR #76696)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 1 23:06:31 PST 2024


https://github.com/ssahasra updated https://github.com/llvm/llvm-project/pull/76696

>From 7806a549b45a8d0cb6e42b66cac93dcecad56207 Mon Sep 17 00:00:00 2001
From: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
Date: Sat, 23 Dec 2023 13:52:18 +0530
Subject: [PATCH 1/2] [AMDGPU] Do not preserve UniformityInfo

UniformityInfo has a transitive dependence on CycleInfo. A transform may change
the CFG in trivial ways that do not affect uniformity, but that can leave cycles
in a slightly inconsistent state. In the absence of updates to CycleInfo, it's
cleaner to just invalidate both analyses.
---
 llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp      | 1 -
 llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
index 459400e3359ca1..79e9312034da45 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
@@ -85,7 +85,6 @@ class AMDGPURewriteUndefForPHILegacy : public FunctionPass {
     AU.addRequired<DominatorTreeWrapperPass>();
 
     AU.addPreserved<DominatorTreeWrapperPass>();
-    AU.addPreserved<UniformityInfoWrapperPass>();
     AU.setPreservesCFG();
   }
 };
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
index 9bc3ba161c9ebe..1bfb7c0edd80a9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
@@ -109,9 +109,6 @@ void AMDGPUUnifyDivergentExitNodes::getAnalysisUsage(AnalysisUsage &AU) const {
     // FIXME: preserve PostDominatorTreeWrapperPass
   }
 
-  // No divergent values are changed, only blocks and branch edges.
-  AU.addPreserved<UniformityInfoWrapperPass>();
-
   // We preserve the non-critical-edgeness property
   AU.addPreservedID(BreakCriticalEdgesID);
 

>From f235ba1bb9a3d17fea9dbf12df83dd131efc7b70 Mon Sep 17 00:00:00 2001
From: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
Date: Tue, 2 Jan 2024 12:35:11 +0530
Subject: [PATCH 2/2] add generic note about not preserving uniformity analysis

---
 llvm/include/llvm/ADT/GenericUniformityImpl.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/include/llvm/ADT/GenericUniformityImpl.h b/llvm/include/llvm/ADT/GenericUniformityImpl.h
index b7d0a1228ebfc0..e05bdd3e7c7ddc 100644
--- a/llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ b/llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -33,6 +33,12 @@
 /// the propagation of the impact of divergent control flow on the divergence of
 /// values (sync dependencies).
 ///
+/// NOTE: In general, no interface exists for a transform to update
+/// (Machine)UniformityInfo. Additionally, (Machine)CycleAnalysis is a
+/// transitive dependence, but it also does not provide an interface for
+/// updation. Given that, transforms should not preserve uniformity in their
+/// getAnalysisUsage() callback.
+///
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_ADT_GENERICUNIFORMITYIMPL_H



More information about the llvm-commits mailing list