[llvm] [VPlan] Handle some VPInstructions in mayReadFromMemory (PR #120058)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 01:13:32 PST 2024


================
@@ -115,6 +115,25 @@ bool VPRecipeBase::mayWriteToMemory() const {
 
 bool VPRecipeBase::mayReadFromMemory() const {
   switch (getVPDefID()) {
+  case VPInstructionSC:
+    if (Instruction::isBinaryOp(cast<VPInstruction>(this)->getOpcode()))
+      return false;
+    switch (cast<VPInstruction>(this)->getOpcode()) {
+    case Instruction::Or:
+    case Instruction::ICmp:
+    case Instruction::Select:
+    case VPInstruction::AnyOf:
+    case VPInstruction::Not:
+    case VPInstruction::CalculateTripCountMinusVF:
+    case VPInstruction::CanonicalIVIncrementForPart:
+    case VPInstruction::ExtractFromEnd:
+    case VPInstruction::FirstOrderRecurrenceSplice:
+    case VPInstruction::LogicalAnd:
+    case VPInstruction::PtrAdd:
+      return false;
+    default:
+      return true;
+    }
----------------
lukel97 wrote:

I'm not sure where to put this, since there's already a `VPRecipeBase::mayReadOrWriteMemory()` and it seems a bit hairy to override that. I could name it something like `VPInstruction::opcodeMayAccessMemory()` or something?

Alternatively, would these end up diverging at some point? Assuming we'll never have a VPInstruction with an ordered load or store we could mark those as free from writes and stores respectively. Or is that out of the scope of this PR?

https://github.com/llvm/llvm-project/pull/120058


More information about the llvm-commits mailing list