[llvm] [VPlan] Remove overlapping VPInstruction::mayWriteToMemory. NFCI (PR #120039)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 01:52:03 PST 2024


https://github.com/lukel97 updated https://github.com/llvm/llvm-project/pull/120039

>From 1011e6316afee8e6aae6869667c3aa3214a11d6b Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 16 Dec 2024 13:50:31 +0800
Subject: [PATCH 1/2] [VPlan] Remove overlapping
 VPInstruction::mayWriteToMemory. NFCI

VPInstruction has a definition of mayWriteToMemory, which seems to only be used by VPlanSLP. However VPInstructions are already handled in VPRecipeBase::mayWriteToMemory, and everywhere else seems to use this definition. I think these should be the same for all intents and purposes. The VPRecipeBase definition is more conservative but returns true for stores/calls/invokes/SLPStores.
---
 llvm/lib/Transforms/Vectorize/VPlan.h          | 8 --------
 llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 2 ++
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index e8902009455ef4..ad1e56c6ef82ec 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1347,14 +1347,6 @@ class VPInstruction : public VPRecipeWithIRFlags,
   LLVM_DUMP_METHOD void dump() const;
 #endif
 
-  /// Return true if this instruction may modify memory.
-  bool mayWriteToMemory() const {
-    // TODO: we can use attributes of the called function to rule out memory
-    //       modifications.
-    return Opcode == Instruction::Store || Opcode == Instruction::Call ||
-           Opcode == Instruction::Invoke || Opcode == SLPStore;
-  }
-
   bool hasResult() const {
     // CallInst may or may not have a result, depending on the called function.
     // Conservatively return calls have results for now.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 4836186525fd6a..92b534b6776367 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -67,6 +67,8 @@ bool VPRecipeBase::mayWriteToMemory() const {
     case VPInstruction::PtrAdd:
       return false;
     default:
+      // TODO: for calls, we can use attributes of the called function to rule
+      // out memory modifications.
       return true;
     }
   case VPInterleaveSC:

>From 65498baa6c36bcb20337fbaac8b3e0285457ec0f Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 16 Dec 2024 17:51:36 +0800
Subject: [PATCH 2/2] Remove TODO about calls

---
 llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 92b534b6776367..4836186525fd6a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -67,8 +67,6 @@ bool VPRecipeBase::mayWriteToMemory() const {
     case VPInstruction::PtrAdd:
       return false;
     default:
-      // TODO: for calls, we can use attributes of the called function to rule
-      // out memory modifications.
       return true;
     }
   case VPInterleaveSC:



More information about the llvm-commits mailing list