[llvm] [VPlan] Forbid CSE'ing writes (PR #207443)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 11:24:10 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
CSE'ing two identical writes does not consider the fact that there could be another write that writes an aliasing memory location. Fix the potential miscompile.
---
Full diff: https://github.com/llvm/llvm-project/pull/207443.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+2-4)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index e5d16ccbec434..0df04dc010381 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2479,10 +2479,8 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> {
C->second == Instruction::ExtractValue)))
return false;
- // During CSE, we can only handle recipes that don't read from memory: if
- // they read from memory, there could be an intervening write to memory
- // before the next instance is CSE'd, leading to an incorrect result.
- return !Def->mayReadFromMemory();
+ // During CSE, we can only handle non-memory recipes, as memory can alias.
+ return !Def->mayReadOrWriteMemory();
}
/// Hash the underlying data of \p Def.
``````````
</details>
https://github.com/llvm/llvm-project/pull/207443
More information about the llvm-commits
mailing list