[llvm] [VectorCombine] Scalarize bin ops and cmps with two splatted operands (PR #137786)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 11:28:04 PDT 2025
================
@@ -1035,50 +1035,61 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
if (match(U, m_Select(m_Specific(&I), m_Value(), m_Value())))
return false;
- // Match against one or both scalar values being inserted into constant
- // vectors:
- // vec_op VecC0, (inselt VecC1, V1, Index)
- // vec_op (inselt VecC0, V0, Index), VecC1
- // vec_op (inselt VecC0, V0, Index), (inselt VecC1, V1, Index)
- // TODO: Deal with mismatched index constants and variable indexes?
Constant *VecC0 = nullptr, *VecC1 = nullptr;
Value *V0 = nullptr, *V1 = nullptr;
- uint64_t Index0 = 0, Index1 = 0;
- if (!match(Ins0, m_InsertElt(m_Constant(VecC0), m_Value(V0),
- m_ConstantInt(Index0))) &&
- !match(Ins0, m_Constant(VecC0)))
- return false;
- if (!match(Ins1, m_InsertElt(m_Constant(VecC1), m_Value(V1),
- m_ConstantInt(Index1))) &&
- !match(Ins1, m_Constant(VecC1)))
- return false;
+ std::optional<uint64_t> Index;
+
+ // Try and match against two splatted operands first.
+ // vec_op (splat V0), (splat V1)
+ V0 = getSplatValue(Ins0);
+ V1 = getSplatValue(Ins1);
+ if (!V0 || !V1) {
----------------
preames wrote:
I think you're going to need this if (!VO) { do something; } if (!V1) { do_something } if (indices don't match) { bail; }
https://github.com/llvm/llvm-project/pull/137786
More information about the llvm-commits
mailing list