[clang] [clang][clangIR]: X86 vperm2f128 builtin implementation (PR #208851)
Lucas Ribeiro Lima via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 18 16:16:57 PDT 2026
================
@@ -811,6 +811,48 @@ static mlir::Value emitX86MaskedLoad(CIRGenBuilderTy &builder,
return builder.createMaskedLoad(loc, ty, ptr, alignment, maskVec, ops[1]);
}
+static mlir::Value emitX86VPerm2f128(CIRGenBuilderTy &builder,
+ mlir::Location loc,
+ llvm::SmallVector<mlir::Value> ops) {
+ auto inputType = cast<cir::VectorType>(ops[0].getType());
+ assert(!inputType.getIsScalable() &&
+ "This is only intended for fixed-width vectors");
+
+ const uint8_t imm = CIRGenFunction::getZExtIntValueFromConstOp(ops[2]) & 0xFF;
+ mlir::Value zeroVec = builder.getZero(loc, inputType);
+
+ // Mirror hardware and OGCG behaviour returning a zero vector
+ if ((imm & 0x80) && (imm & 0x08))
+ return zeroVec;
+
+ mlir::Value lanes[2];
+ llvm::SmallVector<int64_t, 64> mask;
+ const unsigned numElts = inputType.getSize();
+
+ // We must evaluated each lane(128 bits) separetely
+ for (auto lane : llvm::seq(0, 2)) {
+ llvm::Boolean isZeroBit = imm & (1 << ((lane * 4) + 3)),
----------------
lucaslive974 wrote:
I thought was a good idea using llvm specific types than generics. Going to replace for a simple bool.
https://github.com/llvm/llvm-project/pull/208851
More information about the cfe-commits
mailing list