[llvm] [VPlan] Introduce CSE pass (PR #151872)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 04:37:15 PDT 2025


================
@@ -122,6 +122,49 @@ void VPDef::dump() const {
 }
 #endif
 
+bool VPValue::isIdenticalTo(const VPValue *Other) const {
+  if (getVPValueID() != Other->getVPValueID() ||
+      hasDefiningRecipe() != Other->hasDefiningRecipe() ||
+      !getUnderlyingValue() != !Other->getUnderlyingValue())
+    return false;
+
+  auto *I = dyn_cast_or_null<Instruction>(getUnderlyingValue());
+  auto *OtherI = dyn_cast_or_null<Instruction>(Other->getUnderlyingValue());
+  if (I && OtherI)
+    return I->isIdenticalTo(OtherI);
+
+  if (hasDefiningRecipe()) {
+    // Special case for matching flags on instruction.
+    auto *VPI = dyn_cast<VPInstruction>(this);
+    auto *OtherVPI = dyn_cast<VPInstruction>(Other);
+    if (VPI && OtherVPI && VPI->hashFlags() != OtherVPI->hashFlags())
+      return false;
----------------
fhahn wrote:

A lot of other recipes can have flags too. Better handle it by dropping poison generating flags when an instruction is re-used.

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


More information about the llvm-commits mailing list