[llvm] [InstSimplify] Use multi-op replacement when simplify `select` (PR #121708)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 14:25:46 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;
+
+ // For vector types, the simplification must hold per-lane, so forbid
+ // potentially cross-lane operations like shufflevector.
+ if (OpAndRepOp.first->getType()->isVectorTy() &&
+ !isNotCrossLaneOperation(I))
+ continue;
----------------
goldsteinn wrote:
Oh I see, yeah I had it the other way around. I guess we are guarding against `(icmp eq (or x, 1), 0)` which will get simplification elsewhere. Will change.
https://github.com/llvm/llvm-project/pull/121708
More information about the llvm-commits
mailing list