Author: Amr Hesham
Date: 2026-08-29T12:30:09+02:00
New Revision: f1537cf2b5b1d210b2fd7f4dda7c99c07d73a257

URL: 
https://github.com/llvm/llvm-project/commit/f1537cf2b5b1d210b2fd7f4dda7c99c07d73a257
DIFF: 
https://github.com/llvm/llvm-project/commit/f1537cf2b5b1d210b2fd7f4dda7c99c07d73a257.diff

LOG: [CIR] Support fp strict for VecCmpOp in UnaryLNot (#218244)

Support FP strict mode for VecCmpOp in UnaryLNot

Added: 
    clang/test/CIR/CodeGen/vector-strict-fp.cpp

Modified: 
    clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 1bbad1211c0c2..f7a39a9b4a8c9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -2896,10 +2896,8 @@ mlir::Value ScalarExprEmitter::VisitUnaryLNot(const 
UnaryOperator *e) {
     mlir::Value oper = Visit(e->getSubExpr());
     mlir::Location loc = cgf.getLoc(e->getExprLoc());
     auto operVecTy = mlir::cast<cir::VectorType>(oper.getType());
-    auto exprVecTy = 
mlir::cast<cir::VectorType>(cgf.convertType(e->getType()));
     mlir::Value zeroVec = builder.getNullValue(operVecTy, loc);
-    return cir::VecCmpOp::create(builder, loc, exprVecTy, cir::CmpOpKind::eq,
-                                 oper, zeroVec);
+    return builder.createVecCompare(loc, cir::CmpOpKind::eq, oper, zeroVec);
   }
 
   // Compare operand to zero.

diff  --git a/clang/test/CIR/CodeGen/vector-strict-fp.cpp 
b/clang/test/CIR/CodeGen/vector-strict-fp.cpp
new file mode 100644
index 0000000000000..340834200d899
--- /dev/null
+++ b/clang/test/CIR/CodeGen/vector-strict-fp.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value 
-ffp-contract=on -fexperimental-strict-floating-point 
-ffp-exception-behavior=strict -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value 
-ffp-contract=on -fexperimental-strict-floating-point 
-ffp-exception-behavior=strict -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value 
-ffp-contract=on -fexperimental-strict-floating-point 
-ffp-exception-behavior=strict -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+typedef float v4f __attribute__((ext_vector_type(4)));
+typedef int v4i __attribute__((ext_vector_type(4)));
+
+void vec_logical_not() {
+  v4f a;
+  v4i b = !a;
+}
+
+// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!cir.vector<4 x 
!cir.float>>
+// CIR: %[[B_ADDR:.*]] = cir.alloca "b" {{.*}} init : !cir.ptr<!cir.vector<4 x 
!s32i>>
+// CIR: %[[TMP_A:.*]] = cir.load {{.*}} %[[A_ADDR]] : !cir.ptr<!cir.vector<4 x 
!cir.float>>, !cir.vector<4 x !cir.float>
+// CIR: %[[CONST_ZERO:.*]] = cir.const #cir.zero : !cir.vector<4 x !cir.float>
+// CIR: %[[RESULT:.*]] = cir.vec.cmp(eq, %[[TMP_A]], %[[CONST_ZERO]]) : 
!cir.vector<4 x !cir.float>, !cir.vector<4 x !s32i> {fenv = 
#cir.fenv<dynamic_rounding_mode = tonearest, except_mode = unknown, 
strict_except = true>}
+// CIR: cir.store {{.*}} %[[RESULT]], %[[B_ADDR]] : !cir.vector<4 x !s32i>, 
!cir.ptr<!cir.vector<4 x !s32i>>
+
+// LLVM: %[[A_ADDR:.*]] = alloca <4 x float>, align 16
+// LLVM: %[[B_ADDR:.*]] = alloca <4 x i32>, align 16
+// LLVM: %[[TMP_A:.*]] = load <4 x float>, ptr %[[A_ADDR]], align 16
+// LLVM: %[[RESULT:.*]] = call <4 x i1> 
@llvm.experimental.constrained.fcmp.v4f32(<4 x float> %[[TMP_A]], <4 x float> 
zeroinitializer, metadata !"oeq", metadata !"fpexcept.strict")
+// LLVM: %[[RESULT_V4I:.*]] = sext <4 x i1> %[[RESULT]] to <4 x i32>
+// LLVM: store <4 x i32> %[[RESULT_V4I]], ptr %[[B_ADDR]], align 16


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

Reply via email to