[llvm] [InstSimplify] Use multi-op replacement when simplify `select` (PR #121708)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 13:06:58 PST 2025


================
@@ -4316,12 +4309,30 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
   if (isa<FreezeInst>(I))
     return nullptr;
 
+  SmallVector<std::pair<Value *, Value *>> ValidReplacements{};
+  for (const auto &OpAndRepOp : Ops) {
+    // We cannot replace a constant, and shouldn't even try.
+    if (isa<Constant>(OpAndRepOp.first))
+      return nullptr;
----------------
nikic wrote:

I realize this is pre-existing, but I do wonder why this is checked here and not *before* the trivial replacement at the top.

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


More information about the llvm-commits mailing list