[llvm] [InstCombine] Fold patterns which uses <2N x iM> type for comparisons on <N x i2M> vector types (PR #184328)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 06:03:28 PDT 2026
================
@@ -1292,6 +1292,219 @@ Value *InstCombinerImpl::foldUsingDistributiveLaws(BinaryOperator &I) {
return SimplifySelectsFeedingBinaryOp(I, LHS, RHS);
}
+// Folds patterns which uses comparisons on <2N x iM> type for a <N x i2M>
+// equality comparison.
+//
+// (A1, ..., AN) -> (A1Lower, A1Upper, ..., ANLower, ANUpper)
+// (B1, ..., BN) -> (B1Lower, B1Upper, ..., BNLower, BNUpper)
+// (Result1, ..., ResultN) -> (Result1, Result1, ..., ResultN, ResultN)
+//
+// where,
+//
+// ResultX = EqLowerX & EqUpperX
+// EqLowerX = AXLower == BXLower
+// EqUpperX = AXUpper == BXUpper
+//
+// Bitwise AND between the upper and lower parts can be achived by performing
+// the operation between the original and shuffled equality vector.
+static Value *foldVecCmpEqOnHalfElementSize(Instruction &I,
+ FixedVectorType *ResultVecType,
+ InstCombiner::BuilderTy &Builder) {
+ // Check pattern existance
+ Value *L, *R;
+ CmpPredicate Pred;
+ ArrayRef<int> Mask;
+
+ auto Equal = m_SExtOrSelf(m_ICmp(Pred, m_Value(L), m_Value(R)));
----------------
RKSimon wrote:
Are you missing communicative matching? I can't see anything that ensure both L and R values match?
https://github.com/llvm/llvm-project/pull/184328
More information about the llvm-commits
mailing list