[llvm] [LoopVectorize] LLVM fails to vectorise loops with multi-bool varables (PR #89226)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 02:49:54 PDT 2024


================
@@ -635,14 +635,57 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
       return InstDesc(Select, Prev.getRecKind());
   }
 
+  SelectInst *SI = dyn_cast<SelectInst>(I);
+  Instruction *Cmp = nullptr;
+
+  if (SI) {
+    // Check that SelectInst is related to the this PHI reduction.
+    bool HasOrigPhiUser = false;
+    bool SelectNonPHIUserInLoop = false;
+    for (User *U : SI->users()) {
+      Instruction *Inst = dyn_cast<Instruction>(U);
+      if (!Inst)
+        continue;
+      if (Inst == OrigPhi) {
+        HasOrigPhiUser = true;
+      } else {
+        if (Loop->contains(Inst->getParent()))
+          SelectNonPHIUserInLoop = true;
+      }
+    }
+    Cmp = dyn_cast<CmpInst>(SI->getOperand(0));
----------------
sdesmalen-arm wrote:

If the compare used in the `select` has another use which is not part of any reduction, does that mean it's no longer an "any_of" pattern? I would expect `isAnyOfPattern` to still return `true`, but for any further checks to be done somewhere else.

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


More information about the llvm-commits mailing list