[llvm] [IA][RISCV] Recognizing gap masks assembled from bitwise AND (PR #153324)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 13 15:14:59 PDT 2025
================
@@ -601,6 +602,18 @@ static std::pair<Value *, APInt> getMask(Value *WideMask, unsigned Factor,
}
}
+ // Try to match `and <interleaved mask>, <gap mask>`. The WideMask here is
+ // expected to be a fixed vector and gap mask should be a constant mask.
+ Value *AndMaskLHS;
+ Constant *AndMaskRHS;
+ if (LeafValueEC.isFixed() &&
+ match(WideMask, m_c_And(m_Value(AndMaskLHS), m_Constant(AndMaskRHS)))) {
+ assert(!isa<Constant>(AndMaskLHS) &&
+ "expect constants to be folded already");
+ getGapMask(*AndMaskRHS, Factor, LeafValueEC.getFixedValue(), GapMask);
+ return {getMask(AndMaskLHS, Factor, LeafValueEC).first, GapMask};
----------------
mshockwave wrote:
> But we cannot write an assert that says it will not happen.
I think that's a fair point. I've updated the patch to make the logics more general: now it will try to merge both the deinterleaved masks and the gap masks from LHS & RHS.
https://github.com/llvm/llvm-project/pull/153324
More information about the llvm-commits
mailing list