[llvm-branch-commits] [mlir] release/23.x: [mlir] fix builders by moving var into assert (#209494) (PR #212475)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 28 04:46:25 PDT 2026


https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/212475

Backport e217dcb8de5dd83b307fe8b95b43de11a7d894ab

Requested by: @svs-quic

>From edecba892442277314370b0140ee8b382ac8c78b Mon Sep 17 00:00:00 2001
From: George Burgess IV <george.burgess.iv at gmail.com>
Date: Tue, 14 Jul 2026 11:16:22 -0400
Subject: [PATCH] [mlir] fix builders by moving var into assert (#209494)

non-asserts builders are failing since `vecTy` is unused aside from this
one assertion: https://lab.llvm.org/buildbot/#/builders/228/builds/4754

Since side-effects here are uninteresting, move the entire expr into the
assert, per CodingStandards.md

Fix-forward for #199700

(cherry picked from commit e217dcb8de5dd83b307fe8b95b43de11a7d894ab)
---
 mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
index 948229bb53328..e97546f43c159 100644
--- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
+++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
@@ -1807,8 +1807,8 @@ lookupConvOp(const TableEntry (&table)[N], Type srcElemType, Type dstElemType) {
 
 /// Extract a single element from a vector.
 static Value extractElement(ImplicitLocOpBuilder &b, Value srcVec, int idx) {
-  auto vecTy = cast<VectorType>(srcVec.getType());
-  assert(idx >= 0 && idx < vecTy.getNumElements() &&
+  assert(idx >= 0 &&
+         idx < cast<VectorType>(srcVec.getType()).getNumElements() &&
          "extractElement: index out of bounds");
   IntegerType i64Ty = b.getI64Type();
   return b.create<LLVM::ExtractElementOp>(



More information about the llvm-branch-commits mailing list