[llvm] [VPlan] Factor out isUnrolled() helper in VPWidenIntOrFpInductionRecipe. NFC (PR #137635)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 07:06:47 PDT 2025
https://github.com/lukel97 updated https://github.com/llvm/llvm-project/pull/137635
>From 1a2ec3e9de2a30d6645f168ffa072daf7f732209 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 28 Apr 2025 21:54:03 +0800
Subject: [PATCH 1/2] [VPlan] Factor out isUnrolled() helper in
VPWidenIntOrFpInductionRecipe. NFC
Split off from #129508, this generalizes getSplatVFValue and getLastUnrolledPartOperand so they don't need changed if another operand is added.
---
llvm/lib/Transforms/Vectorize/VPlan.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 147ca5b4475b5..73ffacb7cc2f9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1851,6 +1851,8 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
TruncInst *Trunc;
+ bool isUnrolled() const { return getNumOperands() == 5; }
+
public:
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
VPValue *VF, const InductionDescriptor &IndDesc,
@@ -1901,7 +1903,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
VPValue *getSplatVFValue() {
// If the recipe has been unrolled (4 operands), return the VPValue for the
// induction increment.
- return getNumOperands() == 5 ? getOperand(3) : nullptr;
+ return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
}
/// Returns the first defined value as TruncInst, if it is one or nullptr
@@ -1923,7 +1925,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
/// the last unrolled part, if it exists. Returns itself if unrolling did not
/// take place.
VPValue *getLastUnrolledPartOperand() {
- return getNumOperands() == 5 ? getOperand(4) : this;
+ return isUnrolled() ? getOperand(getNumOperands() - 1) : this;
}
};
>From b9b058d6d0f6d90bcd970ac1c164e056f829e074 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 28 Apr 2025 22:06:28 +0800
Subject: [PATCH 2/2] Update comment
---
llvm/lib/Transforms/Vectorize/VPlan.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 73ffacb7cc2f9..6bae45a8e739d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1851,6 +1851,7 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
TruncInst *Trunc;
+ // If this recipe is unrolled it will have 2 additional operands.
bool isUnrolled() const { return getNumOperands() == 5; }
public:
@@ -1901,8 +1902,8 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
const VPValue *getVFValue() const { return getOperand(2); }
VPValue *getSplatVFValue() {
- // If the recipe has been unrolled (4 operands), return the VPValue for the
- // induction increment.
+ // If the recipe has been unrolled return the VPValue for the induction
+ // increment.
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
}
More information about the llvm-commits
mailing list