[llvm] [IR][NFC] Introduce Constant::containsMatchingVectorElement and corresponding matcher m_ContainsMatchingVectorElement (PR #200502)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 08:08:55 PDT 2026
================
@@ -1290,16 +1290,10 @@ Instruction *InstCombinerImpl::commonIDivRemTransforms(BinaryOperator &I) {
// If any element of a constant divisor fixed width vector is zero or undef
// the behavior is undefined and we can fold the whole op to poison.
- auto *Op1C = dyn_cast<Constant>(Op1);
- Type *Ty = I.getType();
- auto *VTy = dyn_cast<FixedVectorType>(Ty);
- if (Op1C && VTy) {
- unsigned NumElts = VTy->getNumElements();
- for (unsigned i = 0; i != NumElts; ++i) {
- Constant *Elt = Op1C->getAggregateElement(i);
- if (Elt && (Elt->isNullValue() || isa<UndefValue>(Elt)))
- return replaceInstUsesWith(I, PoisonValue::get(Ty));
- }
+ if (isa<FixedVectorType>(I.getType()) &&
+ match(Op1, m_ContainsMatchingVectorElement(
+ m_CombineOr(m_Zero(), m_UndefValue())))) {
----------------
artagnon wrote:
Just noting: should be able to change this to m_Zero() in a follow-up? There will hopefully be test updates?
https://github.com/llvm/llvm-project/pull/200502
More information about the llvm-commits
mailing list