[llvm] [SLP]Initial support for copyable elements (non-schedulable only) (PR #140279)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 08:47:52 PDT 2025
================
@@ -1220,6 +1235,48 @@ class InstructionsState {
InstructionsState(Instruction *MainOp, Instruction *AltOp)
: MainOp(MainOp), AltOp(AltOp) {}
static InstructionsState invalid() { return {nullptr, nullptr}; }
+
+ bool isCopyableElement(Value *V) const {
+ assert(valid() && "InstructionsState is invalid.");
+ if (isAltShuffle() || getOpcode() == Instruction::GetElementPtr)
+ return false;
+ auto *I = dyn_cast<Instruction>(V);
+ if (!I && isa<PoisonValue>(V))
+ return false;
+ // FIXME: remove doesNotNeedToBeScheduled() and isa<PHINode>() check once
+ // scheduling is supported.
+ return !I ||
+ (I->getParent() != MainOp->getParent() &&
+ (!isVectorLikeInstWithConstOps(I) ||
+ !isVectorLikeInstWithConstOps(MainOp))) ||
+ (I->getOpcode() != MainOp->getOpcode() &&
+ (isa<PHINode>(I) || doesNotNeedToBeScheduled(I)) &&
+ (!I->isBinaryOp() || getMatchingMainOpOrAltOp(I) != MainOp));
+ }
+
+ bool areInstructionsWithCopyableElements(ArrayRef<Value *> VL) const {
+ assert(valid() && "InstructionsState is invalid.");
+ bool HasAtLeastOneCopyableElement = false;
+ auto IsCopyableElement = [&](Value *V) {
+ bool IsCopyable = isCopyableElement(V);
+ HasAtLeastOneCopyableElement |= IsCopyable;
+ return IsCopyable;
+ };
+ return !isAltShuffle() && all_of(VL, [&](Value *V) {
----------------
RKSimon wrote:
early out and simplify logic:
```
if (isAltShuffle())
return false;
if (all_of(......
```
https://github.com/llvm/llvm-project/pull/140279
More information about the llvm-commits
mailing list