[llvm] [SLP] Extract isIdentityOrder to common routine [probably NFC] (PR #106582)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 09:50:01 PDT 2024
================
@@ -1364,6 +1364,19 @@ class BoUpSLP {
/// Perform LICM and CSE on the newly generated gather sequences.
void optimizeGatherSequence();
+ /// Does this non-empty order represent an identity order? Identity
+ /// should be represented as an empty order, so this is used to
+ /// decide if we can canonicalize a computed order. Undef elements
+ /// (represented as size) are ignored.
+ bool IsIdentityOrder(ArrayRef<unsigned> Order) const {
+ assert(!Order.empty());
+ const unsigned Sz = Order.size();
+ for (unsigned Idx : seq<unsigned>(0, Sz))
+ if (Idx != Order[Idx] && Order[Idx] != Sz)
+ return false;
+ return true;
----------------
alexey-bataev wrote:
`return all_of(enumerate(Order), [&](const auto &P) { return P.value() == P.index() || P.value() == Sz; });`
https://github.com/llvm/llvm-project/pull/106582
More information about the llvm-commits
mailing list