[llvm] [LV] Fix FindLastIV reduction for epilogue vectorization. (PR #120395)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 01:06:55 PST 2025


================
@@ -7687,6 +7687,19 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
            "AnyOf expected to start by comparing main resume value to original "
            "start value");
     MainResumeValue = Cmp->getOperand(0);
+  } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(
+                 RdxDesc.getRecurrenceKind())) {
+    using namespace llvm::PatternMatch;
+    Value *Cmp, *OrigResumeV;
+    bool IsExpectedPattern =
+        match(MainResumeValue, m_Select(m_OneUse(m_Value(Cmp)),
+                                        m_Specific(RdxDesc.getSentinelValue()),
+                                        m_Value(OrigResumeV))) &&
+        match(Cmp,
+              m_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(OrigResumeV),
+                             m_Specific(RdxDesc.getRecurrenceStartValue())));
+    assert(IsExpectedPattern && "Unexpected reduction resume pattern");
----------------
fhahn wrote:

```suggestion
    assert(IsExpectedPattern && "Unexpected reduction resume pattern");
    (void) IsExpectedPattern;
```

to avoid warning on release builds

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


More information about the llvm-commits mailing list