https://github.com/darkbuck created 
https://github.com/llvm/llvm-project/pull/220022

- After #218887, the constant verification is tightened and requires matching 
attr and res types. Fix one violation when lowering `cir.not`.

>From 022b550405579ade8c8eb23cfbc1d19a4f2dd6d7 Mon Sep 17 00:00:00 2001
From: Michael Liao <[email protected]>
Date: Mon, 31 Aug 2026 12:44:28 -0400
Subject: [PATCH] [CIR] Fix `llvm.mlir.constant` creation

- After #218887, the constant verification is tightened and requires
  matching attr and res types. Fix one violation when lowering
  `cir.not`.
---
 clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 6a5a0b4163f39..6196ff45b7293 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -3211,8 +3211,11 @@ mlir::LogicalResult 
CIRToLLVMNotOpLowering::matchAndRewrite(
     if (isVector) {
       const uint64_t numElements =
           mlir::cast<cir::VectorType>(op.getType()).getSize();
-      SmallVector<int32_t> values(numElements, -1);
-      mlir::DenseIntElementsAttr denseVec = rewriter.getI32VectorAttr(values);
+      const unsigned eltWidth =
+          mlir::cast<cir::IntType>(elementType).getWidth();
+      SmallVector<APInt> values(numElements, APInt::getAllOnes(eltWidth));
+      mlir::DenseIntElementsAttr denseVec = mlir::DenseIntElementsAttr::get(
+          mlir::cast<mlir::ShapedType>(llvmType), values);
       minusOne =
           mlir::LLVM::ConstantOp::create(rewriter, loc, llvmType, denseVec);
     } else {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to