================
@@ -811,6 +811,53 @@ 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, mlir::Type resType,
+ llvm::SmallVector<mlir::Value> ops) {
+ auto inputType = cast<cir::VectorType>(ops[0].getType());
+ const unsigned imm = CIRGenFunction::getZExtIntValueFromConstOp(ops[2]);
+ const uint8_t zeroMask = 0x08, controlMask = 0x0F;
+
+ // Mirror hardware and OGCG behaviour returning a zero vector
+ if ((imm & zeroMask) && (imm & zeroMask << 4))
+ return builder.getZero(loc, resType);
+
+ 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)) {
+ uint8_t controlBits = (imm >> (lane * 4)) & controlMask;
+
+ llvm::Boolean isZeroBit = controlBits & zeroMask;
+ llvm::Boolean isSourceA = controlBits <= 1;
+ llvm::Boolean isLowerHalf = controlBits % 2 == 0;
+
+ // Determine the source for this lane
+ if (isZeroBit)
+ lanes[lane] = builder.getZero(loc, resType);
+ else
+ lanes[lane] = isSourceA ? ops[0] : ops[1];
+
+ // We need to built the shuffle mask selecting the right half
+ for (auto elt : llvm::seq(0u, numElts / 2u)) {
+ unsigned idx = (lane * numElts) + elt;
+ if (!isLowerHalf)
+ idx += numElts / 2;
+ mask.push_back(idx);
+ }
+ }
+
+ mlir::Value shuffleResult =
+ builder.createVecShuffle(loc, lanes[0], lanes[1], mask);
+
+ if (inputType != resType)
+ builder.createBitcast(shuffleResult, resType);
----------------
lucaslive974 wrote:
In fact, this doesnt seems to ever happen, so i'm removing this branching.
https://github.com/llvm/llvm-project/pull/208851
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits