================
@@ -501,19 +417,91 @@ static mlir::Value emitX86vpcom(CIRGenBuilderTy &builder,
mlir::Location loc,
return builder.createVecCompare(loc, pred, op0, op1);
}
-std::optional<mlir::Value>
-CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) {
+static mlir::Value emitX86MaskedCompare(CIRGenBuilderTy &builder,
+ mlir::Location loc,
+ llvm::SmallVector<mlir::Value> ops,
+ bool isSigned = true) {
+
+ uint64_t imm = CIRGenFunction::getZExtIntValueFromConstOp(ops[2]) & 0x7;
+ cir::VectorType ty = cast<cir::VectorType>(ops[0].getType());
+ cir::IntType elementTy = cast<cir::IntType>(ty.getElementType());
+ unsigned numElts = ty.getSize();
+ mlir::Value cmp;
+ if (imm == 3) {
+ cmp = builder.getNullValue(
+ cir::VectorType::get(builder.getSIntNTy(1), numElts), loc);
+ } else if (imm == 7) {
+ llvm::APInt allOnes = llvm::APInt::getAllOnes(elementTy.getWidth());
+ cmp = cir::VecSplatOp::create(
+ builder, loc, ty, builder.getConstAPInt(loc, elementTy, allOnes));
+ } else {
+ cir::CmpOpKind pred;
+ switch (imm) {
+ default:
+ llvm_unreachable("Unknown condition code");
+ case 0:
+ pred = cir::CmpOpKind::eq;
+ break;
+ case 1:
+ pred = cir::CmpOpKind::lt;
+ break;
+ case 2:
+ pred = cir::CmpOpKind::le;
+ break;
+ case 4:
+ pred = cir::CmpOpKind::ne;
+ break;
+ case 5:
+ pred = cir::CmpOpKind::ge;
+ break;
+ case 6:
+ pred = cir::CmpOpKind::gt;
+ break;
+ }
----------------
xlauko wrote:
refactor to
```
static cir::CmpOpKind getCmpPredFromImm(unsigned imm) {
switch (imm) {
case 0: return cir::CmpOpKind::eq;
case 1: return cir::CmpOpKind::lt;
case 2: return cir::CmpOpKind::le;
case 4: return cir::CmpOpKind::ne;
case 5: return cir::CmpOpKind::ge;
case 6: return cir::CmpOpKind::gt;
default:
llvm_unreachable("Unknown condition code");
}
}
```
https://github.com/llvm/llvm-project/pull/174318
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits