[llvm] [VPlan] Mark Scalar instruction as not predicated (PR #95191)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 19:30:47 PDT 2024


https://github.com/eastB233 created https://github.com/llvm/llvm-project/pull/95191

It tries to fix https://github.com/llvm/llvm-project/issues/94328

>From what I understand so far, as recorded in the issue, I think
an instruction that would be scalar after vectorization shoud be
marked as not predicated.

>From 2a014b9d9e083ee10f0d181811957c1420d21790 Mon Sep 17 00:00:00 2001
From: Zhiheng Xie <eastb233 at qq.com>
Date: Wed, 12 Jun 2024 10:07:58 +0800
Subject: [PATCH] [VPlan] Mark Scalar instruction as not predicated

For instruction that is still scalar after vectorization,
mark it as not predicated.

Fixes https://github.com/llvm/llvm-project/issues/94328
---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c7c19ef456c7c..3c1520746c988 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8326,7 +8326,11 @@ VPReplicateRecipe *VPRecipeBuilder::handleReplication(Instruction *I,
       [&](ElementCount VF) { return CM.isUniformAfterVectorization(I, VF); },
       Range);
 
-  bool IsPredicated = CM.isPredicatedInst(I);
+  bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
+      [&](ElementCount VF) {
+        return CM.isPredicatedInst(I) && !CM.isScalarAfterVectorization(I, VF);
+      },
+      Range);
 
   // Even if the instruction is not marked as uniform, there are certain
   // intrinsic calls that can be effectively treated as such, so we check for



More information about the llvm-commits mailing list