https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/216133
Support lowering the constant vector of booleans as an element type >From 12cf3ce416949abe6b6d5e3c1d101de3b31ba629 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Thu, 13 Aug 2026 19:53:15 +0200 Subject: [PATCH] [CIR] Support Const vector of bool --- clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 6 ++++-- clang/test/CIR/CodeGen/vector-bool.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index ccdc974ca1b93..ec499301434e8 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -801,9 +801,11 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::ConstVectorAttr attr) { } else if (auto floatAttr = mlir::dyn_cast<cir::FPAttr>(elementAttr)) { mlirAttr = rewriter.getFloatAttr( converter->convertType(floatAttr.getType()), floatAttr.getValue()); + } else if (auto boolAttr = mlir::dyn_cast<cir::BoolAttr>(elementAttr)) { + mlirAttr = rewriter.getBoolAttr(boolAttr.getValue()); } else { - llvm_unreachable( - "vector constant with an element that is neither an int nor a float"); + llvm_unreachable("vector constant with an element that is neither an " + "int, a float, or a bool"); } mlirValues.push_back(mlirAttr); } diff --git a/clang/test/CIR/CodeGen/vector-bool.cpp b/clang/test/CIR/CodeGen/vector-bool.cpp index 724d8109b048a..e01928b74f29c 100644 --- a/clang/test/CIR/CodeGen/vector-bool.cpp +++ b/clang/test/CIR/CodeGen/vector-bool.cpp @@ -7,6 +7,17 @@ typedef bool v8b __attribute__((ext_vector_type(8))); +void constant_vec_bool() { + v8b a = {true, false, true, false, true, false, true, false}; +} + +// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.vector<8 x !cir.bool>> +// CIR: %[[CONST_VEC:.*]] = cir.const #cir.const_vector<[#true, #false, #true, #false, #true, #false, #true, #false]> : !cir.vector<8 x !cir.bool> +// CIR: cir.store {{.*}} %[[CONST_VEC]], %[[A_ADDR]] : !cir.vector<8 x !cir.bool>, !cir.ptr<!cir.vector<8 x !cir.bool>> + +// LLVM: %[[A_ADDR:.*]] = alloca i8, align 1 +// LLVM: store i8 85, ptr %[[A_ADDR]], align 1 + void vec_bool_without_padding_needed() { v8b a; v8b b; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
