[llvm] [HashRecognize] Recognize trunc-to-i1 little-endian bit check (PR #213883)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 04:26:39 PDT 2026


================
@@ -172,16 +173,25 @@ isSignificantBitCheckWellFormed(const RecurrenceInfo &ConditionalRecurrence,
   const Value *L;
   const APInt *R;
   Instruction *TV, *FV;
-  if (!match(SI, m_Select(m_ICmp(Pred, m_Value(L), m_APInt(R)),
-                          m_Instruction(TV), m_Instruction(FV))))
-    return false;
 
   // Match predicate with or without a SimpleRecurrence (the corresponding data
   // is LHSAux).
   auto MatchPred = m_CombineOr(
       m_Specific(ConditionalRecurrence.Phi),
       m_c_Xor(m_ZExtOrTruncOrSelf(m_Specific(ConditionalRecurrence.Phi)),
               m_ZExtOrTruncOrSelf(m_Specific(SimpleRecurrence.Phi))));
+
+  BinaryOperator *BitShift = ConditionalRecurrence.BO;
+  auto MatchBitShiftXorGenPoly = m_c_Xor(
+      m_Specific(BitShift), m_SpecificInt(*ConditionalRecurrence.ExtraConst));
+  if (!IsBigEndian &&
+      match(SI, m_Select(m_Trunc(MatchPred), MatchBitShiftXorGenPoly,
+                         m_Specific(BitShift))))
+    return true;
----------------
artagnon wrote:

This would be incorrect, because it would bail on big-endian, but perhaps what we really need is to chain the two matchers together, for a correct early-exit?

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


More information about the llvm-commits mailing list