[llvm] [SLP] NFC. Add assert for shouldBroadcast and canBeVectorized. (PR #119327)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 21:27:23 PST 2024


https://github.com/HanKuanChen created https://github.com/llvm/llvm-project/pull/119327

None

>From 15d7b0a4d3834585d3d66f392ed343ba40a3fbf5 Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Tue, 19 Nov 2024 00:57:56 -0800
Subject: [PATCH] [SLP] NFC. Add assert for shouldBroadcast and
 canBeVectorized.

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 50590e51ae0ed7..dd1e53a05ebeb8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2460,6 +2460,8 @@ class BoUpSLP {
     /// the whole vector (it is mixed with constants or loop invariant values).
     /// Note: This modifies the 'IsUsed' flag, so a cleanUsed() must follow.
     bool shouldBroadcast(Value *Op, unsigned OpIdx, unsigned Lane) {
+      assert(Op == getValue(OpIdx, Lane) &&
+             "Op is expected to be getValue(OpIdx, Lane).");
       // Small number of loads - try load matching.
       if (isa<LoadInst>(Op) && getNumLanes() == 2 && getNumOperands() == 2)
         return false;
@@ -2517,6 +2519,8 @@ class BoUpSLP {
     /// Checks if there is at least single compatible operand in lanes other
     /// than \p Lane, compatible with the operand \p Op.
     bool canBeVectorized(Instruction *Op, unsigned OpIdx, unsigned Lane) const {
+      assert(Op == getValue(OpIdx, Lane) &&
+             "Op is expected to be getValue(OpIdx, Lane).");
       bool OpAPO = getData(OpIdx, Lane).APO;
       for (unsigned Ln = 0, Lns = getNumLanes(); Ln != Lns; ++Ln) {
         if (Ln == Lane)



More information about the llvm-commits mailing list