https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/217089
Support the Vector of bool type in the minus operation >From b9843d6fa4f21510c5ec5e879f8cc9f22a7960c3 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Tue, 18 Aug 2026 19:25:53 +0200 Subject: [PATCH] [CIR] Support vector of boolean in cir.minus op --- clang/include/clang/CIR/Dialect/IR/CIROps.td | 2 +- .../CIR/Dialect/IR/CIRTypeConstraints.td | 6 ++++++ clang/test/CIR/CodeGen/vector-bool.cpp | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index fbb71206b2a89..3e72c6889566f 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -2051,7 +2051,7 @@ def CIR_DecOp //===----------------------------------------------------------------------===// def CIR_MinusOp - : CIR_UnaryOpWithOverflowFlag<"minus", CIR_AnyIntOrVecOfIntType> { + : CIR_UnaryOpWithOverflowFlag<"minus", CIR_AnyIntOrVecOfIntOrBoolType> { let summary = "Integer unary minus (negation)"; let description = [{ The `cir.minus` operation negates the operand. The operand and result diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td index afdd732a5867f..2f8029c355109 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td @@ -342,6 +342,12 @@ def CIR_AnyIntOrVecOfIntType let cppFunctionName = "isIntOrVectorOfIntType"; } +def CIR_AnyIntOrVecOfIntOrBoolType + : AnyTypeOf<[CIR_AnyIntType, CIR_VectorOfIntOrBoolType], + "integer or vector of bool or integer type"> { + let cppFunctionName = "isIntOrVecOfIntOrBoolType"; +} + def CIR_AnySIntOrVecOfSIntType : AnyTypeOf<[CIR_AnySIntType, CIR_VectorOfSIntType], "signed integer or vector of signed integer type"> { diff --git a/clang/test/CIR/CodeGen/vector-bool.cpp b/clang/test/CIR/CodeGen/vector-bool.cpp index 4e6f95902b81e..9033b60a0a459 100644 --- a/clang/test/CIR/CodeGen/vector-bool.cpp +++ b/clang/test/CIR/CodeGen/vector-bool.cpp @@ -233,3 +233,22 @@ void vec_bool_bitwise_operators() { // SHARED: %[[XOR:.*]] = xor <8 x i1> %[[TMP_A_VEC]], %[[TMP_B_VEC]] // SHARED: %[[XOR_I8:.*]] = bitcast <8 x i1> %[[XOR]] to i8 // SHARED: store i8 %[[XOR_I8]], ptr %[[XOR_ADDR]], align 1 + +void vec_bool_minus_op() { + v8b a; + v8b b = -a; +} + +// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.vector<8 x !cir.bool>> +// CIR: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.vector<8 x !cir.bool>> +// CIR: %[[TMP_A:.*]] = cir.load {{.*}} %[[A_ADDR]] : !cir.ptr<!cir.vector<8 x !cir.bool>>, !cir.vector<8 x !cir.bool> +// CIR: %[[RESULT:.*]] = cir.minus %[[TMP_A]] : !cir.vector<8 x !cir.bool> +// CIR: cir.store {{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.vector<8 x !cir.bool>, !cir.ptr<!cir.vector<8 x !cir.bool>> + +// SHARED: %[[A_ADDR:.*]] = alloca i8, align 1 +// SHARED: %[[B_ADDR:.*]] = alloca i8, align 1 +// SHARED: %[[TMP_A:.*]] = load i8, ptr %[[A_ADDR]], align 1 +// SHARED: %[[TMP_A_VEC:.*]] = bitcast i8 %[[TMP_A]] to <8 x i1> +// SHARED: %[[RESULT:.*]] = sub <8 x i1> zeroinitializer, %[[TMP_A_VEC]] +// SHARED: %[[RESULT_I8:.*]] = bitcast <8 x i1> %[[RESULT]] to i8 +// SHARED: store i8 %[[RESULT_I8]], ptr %[[B_ADDR]], align 1 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
