[llvm] Fold patterns which uses <2N x iM> type for comparisons on <N x 2iM> type (PR #184328)

Fuad Ismail via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 19:38:55 PDT 2026


================
@@ -1296,6 +1296,143 @@ Value *InstCombinerImpl::foldUsingDistributiveLaws(BinaryOperator &I) {
   return SimplifySelectsFeedingBinaryOp(I, LHS, RHS);
 }
 
+// Prior to SSE4.1, to perform equality comparisons between two
+// v2i64 values, the comparison is performed on v4i32 values:
+//
+// (A1, A2) -> (A1Lower, A1Upper, A2Lower, A2Upper)
+// (B1, B2) -> (B1Lower, B1Upper, B2Lower, B2Upper)
+// (Result1, Result2) -> (Result1, Result1, Result2, Result2)
+//
+// 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.
+Instruction *InstCombinerImpl::foldV4EqualShuffleAndToV2Equal(Instruction &I) {
+  // Check argument type
+  auto *OldVecType = dyn_cast<VectorType>(I.getType());
+
+  if (!OldVecType || OldVecType->isScalableTy() ||
+      !OldVecType->getElementType()->isIntegerTy(32) ||
+      OldVecType->getElementCount().getFixedValue() != 4)
+    return nullptr;
----------------
fuad1502 wrote:

Updated in commit https://github.com/llvm/llvm-project/pull/184328/commits/63b94bcc765761d22065167a11f0988a446bc286 to https://github.com/llvm/llvm-project/pull/184328/commits/847d9e1ef78f558b72b2b80f375de8277b9dab65

https://github.com/llvm/llvm-project/pull/184328


More information about the llvm-commits mailing list