[llvm] [NFC][VPlan] Mark VPInstruction::VScale as uniformity-preserving (PR #194674)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 09:46:05 PDT 2026
https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/194674
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.
>From 3920b91e6384d7151e2dac3f0962ddda32c21089 Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Tue, 28 Apr 2026 09:05:52 -0700
Subject: [PATCH] [NFC][VPlan] Mark VPInstruction::VScale as
uniformity-preserving
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.
---
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 1 +
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp | 10 ++++++++++
2 files changed, 11 insertions(+)
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();
More information about the llvm-commits
mailing list