[llvm] [NFC][AMDGPU][Attributor] Exit earlier if entry CC (PR #114177)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 21:22:45 PDT 2024


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/114177

Avoid calling TTI or other stuff unnecessarily

>From a978ebd9492d21c4a21817e6c1168d9eb84bc8c7 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Wed, 30 Oct 2024 00:21:38 -0400
Subject: [PATCH] [NFC][AMDGPU][Attributor] Exit earlier if entry CC

Avoid calling TTI or other stuff unnecessarily
---
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index 6a69b9d2bfc716..04d3e482359ade 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -767,14 +767,17 @@ struct AAAMDFlatWorkGroupSize : public AAAMDSizeRangeAttribute {
 
   void initialize(Attributor &A) override {
     Function *F = getAssociatedFunction();
+
+    if (AMDGPU::isEntryFunctionCC(F->getCallingConv())) {
+      indicatePessimisticFixpoint();
+      return;
+    }
+
     auto &InfoCache = static_cast<AMDGPUInformationCache &>(A.getInfoCache());
     unsigned MinGroupSize, MaxGroupSize;
     std::tie(MinGroupSize, MaxGroupSize) = InfoCache.getFlatWorkGroupSizes(*F);
     intersectKnown(
         ConstantRange(APInt(32, MinGroupSize), APInt(32, MaxGroupSize + 1)));
-
-    if (AMDGPU::isEntryFunctionCC(F->getCallingConv()))
-      indicatePessimisticFixpoint();
   }
 
   ChangeStatus updateImpl(Attributor &A) override {
@@ -833,6 +836,12 @@ struct AAAMDWavesPerEU : public AAAMDSizeRangeAttribute {
 
   void initialize(Attributor &A) override {
     Function *F = getAssociatedFunction();
+
+    if (AMDGPU::isEntryFunctionCC(F->getCallingConv())) {
+      indicatePessimisticFixpoint();
+      return;
+    }
+
     auto &InfoCache = static_cast<AMDGPUInformationCache &>(A.getInfoCache());
 
     if (const auto *AssumedGroupSize = A.getAAFor<AAAMDFlatWorkGroupSize>(
@@ -847,9 +856,6 @@ struct AAAMDWavesPerEU : public AAAMDSizeRangeAttribute {
       ConstantRange Range(APInt(32, Min), APInt(32, Max + 1));
       intersectKnown(Range);
     }
-
-    if (AMDGPU::isEntryFunctionCC(F->getCallingConv()))
-      indicatePessimisticFixpoint();
   }
 
   ChangeStatus updateImpl(Attributor &A) override {



More information about the llvm-commits mailing list