[llvm] 980531c - [VPlan] Fix MayReadFromMemory/MayWriteToMemory on VPWidenIntrinsicRecipe (#136684)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 22 07:50:15 PDT 2025


Author: Luke Lau
Date: 2025-04-22T22:50:12+08:00
New Revision: 980531cac0988e509425e64fbd279ee98e25307c

URL: https://github.com/llvm/llvm-project/commit/980531cac0988e509425e64fbd279ee98e25307c
DIFF: https://github.com/llvm/llvm-project/commit/980531cac0988e509425e64fbd279ee98e25307c.diff

LOG: [VPlan] Fix MayReadFromMemory/MayWriteToMemory on VPWidenIntrinsicRecipe (#136684)

These seem to be the wrong way round, e.g. see the definition at
Instruction::mayReadFromMemory().
If an instruction only writes to memory then it's known to not read
memory, and so on.

Only noticed this when using VPWidenIntrinsicRecipe in a local patch and
wondered why it kept on getting DCEd despite the intrinsic writing to
memory.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index fdcee2bd28997..0f2aac146e7a6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1322,8 +1322,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
     LLVMContext &Ctx = Ty->getContext();
     AttributeSet Attrs = Intrinsic::getFnAttributes(Ctx, VectorIntrinsicID);
     MemoryEffects ME = Attrs.getMemoryEffects();
-    MayReadFromMemory = ME.onlyWritesMemory();
-    MayWriteToMemory = ME.onlyReadsMemory();
+    MayReadFromMemory = !ME.onlyWritesMemory();
+    MayWriteToMemory = !ME.onlyReadsMemory();
     MayHaveSideEffects = MayWriteToMemory ||
                          !Attrs.hasAttribute(Attribute::NoUnwind) ||
                          !Attrs.hasAttribute(Attribute::WillReturn);


        


More information about the llvm-commits mailing list