[llvm] [WPD] Remove type test assumes through PHI and select nodes (PR #224155)

Michael Park via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 01:05:16 PDT 2026


================
@@ -2084,9 +2085,56 @@ bool DevirtModule::areRemarksEnabled() {
   return false;
 }
 
+/// Find assumes whose conditions depend on this type test through phi or select
+/// nodes. SimplifyCFG can produce these patterns by merging type test + assume
+/// sequences from different predecessors.
+static void
+findAssumesThroughMergesForTypeTest(SmallVectorImpl<CallInst *> &Assumes,
+                                    CallInst &TypeTest,
+                                    SmallPtrSetImpl<Value *> &VisitedMerges) {
+  SmallVector<Value *, 4> Worklist;
+
+  auto GetMergeUser = [](User *U, Value *V) -> Value * {
+    if (isa<PHINode>(U))
+      return U;
+    if (auto *Select = dyn_cast<SelectInst>(U);
+        Select && (Select->getTrueValue() == V || Select->getFalseValue() == V))
+      return Select;
+    return nullptr;
+  };
+
+  // Direct assume users were already collected by
----------------
mpark wrote:

I think so. Added.

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


More information about the llvm-commits mailing list