[clang] [CIR] Upstream support for logical not operations (PR #133966)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 3 11:52:32 PDT 2025


================
@@ -1358,6 +1360,33 @@ mlir::Value CIRGenFunction::emitScalarConversion(mlir::Value src,
       .emitScalarConversion(src, srcTy, dstTy, loc);
 }
 
+mlir::Value ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *e) {
+  // Perform vector logical not on comparison with zero vector.
+  if (e->getType()->isVectorType() &&
+      e->getType()->castAs<VectorType>()->getVectorKind() ==
+          VectorKind::Generic) {
+    assert(!cir::MissingFeatures::vectorType());
+    cgf.cgm.errorNYI(e->getSourceRange(), "vector logical not");
+    return {};
+  }
+
+  // Compare operand to zero.
+  mlir::Value boolVal = cgf.evaluateExprAsBool(e->getSubExpr());
----------------
andykaylor wrote:

I wondered about that. This may be something we just blindly brought over from the classic codegen, which does the same thing. I'll try changing it there and run the regression tests to see if anything fails. If not, I'll remove it here.

https://github.com/llvm/llvm-project/pull/133966


More information about the cfe-commits mailing list