[llvm] [NFC][VPlan] Mark VPInstruction::VScale as uniformity-preserving (PR #194674)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 09:46:45 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: Madhur Amilkanthwar (madhur13490)
<details>
<summary>Changes</summary>
VPInstruction::VScale produces the runtime vscale (a scalar) and is by construction loop-invariant and identical across all VF lanes and UF unroll parts. The classifier in VPlanUtils.cpp::preservesUniformity currently does not list VScale, so any user that depends on it is treated as non-uniform-across-VF-and-UF.
This is largely NFC patch.
---
Full diff: https://github.com/llvm/llvm-project/pull/194674.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.cpp (+1)
- (modified) llvm/unittests/Transforms/Vectorize/VPlanTest.cpp (+10)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index 0cb64b66e5ccd..9ec0831cde516 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -353,6 +353,7 @@ static bool preservesUniformity(unsigned Opcode) {
case VPInstruction::Broadcast:
case VPInstruction::MaskedCond:
case VPInstruction::PtrAdd:
+ case VPInstruction::VScale:
return true;
default:
return false;
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index a1ddda7eda969..a050ac15efafe 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -10,6 +10,7 @@
#include "../lib/Transforms/Vectorize/VPlan.h"
#include "../lib/Transforms/Vectorize/VPlanCFG.h"
#include "../lib/Transforms/Vectorize/VPlanHelpers.h"
+#include "../lib/Transforms/Vectorize/VPlanUtils.h"
#include "VPlanTestBase.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/PostOrderIterator.h"
@@ -1787,6 +1788,15 @@ TEST_F(VPInstructionTest, VPSymbolicValueMaterialization) {
EXPECT_TRUE(Plan.getVF().isMaterialized());
}
+using VPUtilsTest = VPlanTestBase;
+
+TEST_F(VPUtilsTest, IsUniformAcrossVFsAndUFsForVScale) {
+ std::unique_ptr<VPInstruction> VScale(
+ new VPInstruction(VPInstruction::VScale, {}));
+
+ EXPECT_TRUE(vputils::isUniformAcrossVFsAndUFs(VScale.get()));
+}
+
#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
TEST_F(VPInstructionTest, VPSymbolicValueAddUserAfterMaterialization) {
VPlan &Plan = getPlan();
``````````
</details>
https://github.com/llvm/llvm-project/pull/194674
More information about the llvm-commits
mailing list