================
@@ -88,6 +88,54 @@ findARMVectorIntrinsicInMap(ArrayRef<AArch64BuiltinInfo> 
intrinsicMap,
   return nullptr;
 }
 
+//===----------------------------------------------------------------------===//
+//  Emit-helpers
+//===----------------------------------------------------------------------===//
+mlir::Value CIRGenFunction::emitAArch64CompareBuiltinExpr(
+    mlir::Location loc, mlir::Value src, mlir::Type ty,
+    const llvm::CmpInst::Predicate pred) {
+
+  mlir::Value res;
+  if (isa<cir::VectorType>(ty) && !cast<cir::VectorType>(ty).getIsScalable()) {
+    // Vector types are cast to i8 vectors. Recover original type.
+    cgm.errorNYI(loc, std::string("unimplemented vector compare"));
+  }
+
+  // Scalar compare is a special case that is artifically converted to a
+  // 1-element vector compare. This is to guarantee that the output result is
+  // sign- rather than zero-extended.
+  //
+  // Specifically, a compare Op will generate an i1 result that needs to be
+  // extended to match the in/out type, `ty`. Regular scalar cast wwould lead
+  // to ZExt to preserve the value, e.g. 0b1 --> 0x00000001 (i1 -0> i16).
+  // Vector compare are meant to generate masks and these are exteded via SExt,
+  // so that 0b1 --> 0x11111111 and 0b0 --> 0x00000000.
+  bool scalarInputs = isa<cir::IntType>(src.getType());
+
+  mlir::Value zero = builder.getNullValue(ty, loc);
+  if (CmpInst::isFPPredicate(pred)) {
----------------
andykaylor wrote:

We don't have FP-specific predicates in CIR. Can you check to see if `ty` (or 
the vector element type) is fp (`mlir::isa<cir::FPTypeInterface>(ty)`?

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

Reply via email to