[llvm] [SLP] Make getSameOpcode support interchangeable instructions. (PR #127450)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 02:15:04 PST 2025


================
@@ -8501,8 +8735,12 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
 
   BlockScheduling &BS = *BSRef;
 
+  SmallVector<Value *> MainOpIsTheFirst(UniqueValues);
+  auto MainOpIter = find(MainOpIsTheFirst, S.getMainOp());
+  std::rotate(MainOpIsTheFirst.begin(), MainOpIter, std::next(MainOpIter));
+
   std::optional<ScheduleData *> Bundle =
-      BS.tryScheduleBundle(UniqueValues, this, S);
+      BS.tryScheduleBundle(MainOpIsTheFirst, this, S);
----------------
HanKuanChen wrote:

`assert(VL[0] == S.getMainOp() && "MainOp must be the first element of VL.");` is added in the beginning of `tryScheduleBundle`.

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


More information about the llvm-commits mailing list