[clang] [llvm] [CIR] Support x86 builtin rotate (PR #169566)
Omar Hossam via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 11:06:32 PST 2025
================
@@ -90,6 +92,41 @@ static mlir::Value getMaskVecValue(CIRGenFunction &cgf, const CallExpr *expr,
return maskVec;
}
+static mlir::Value emitX86FunnelShift(CIRGenFunction &cgf, const CallExpr *e,
+ mlir::Value &op0, mlir::Value &op1,
+ mlir::Value &amt, bool isRight) {
+ auto &builder = cgf.getBuilder();
+ auto op0Ty = op0.getType();
+
+ // Amount may be scalar immediate, in which case create a splat vector.
+ // Funnel shifts amounts are treated as modulo and types are all power-of-2
+ // so we only care about the lowest log2 bits anyway.
+ if (amt.getType() != op0Ty) {
+ auto vecTy = mlir::cast<cir::VectorType>(op0Ty);
+ auto numElems = vecTy.getSize();
+
+ auto amtTy = mlir::cast<cir::IntType>(amt.getType());
+ auto vecElemTy = mlir::cast<cir::IntType>(vecTy.getElementType());
+
+ // Cast to same width unsigned if not already unsigned.
+ if (amtTy.isSigned()) {
+ auto unsignedAmtTy = builder.getUIntNTy(amtTy.getWidth());
+ amt = builder.createIntCast(amt,
+ builder.getUIntNTy(unsignedAmtTy.getWidth()));
----------------
moar55 wrote:
Ah yes, oops
https://github.com/llvm/llvm-project/pull/169566
More information about the llvm-commits
mailing list