llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: awayzjj <details> <summary>Changes</summary> Lower the builtin to cir.fshr (and then llvm.fshr), matching classic CodeGen. Fixes part of #<!-- -->241525. --- Full diff: https://github.com/llvm/llvm-project/pull/242166.diff 2 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp (+6-4) - (modified) clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip (+9) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp index 81e2509efeb4c..0f28dec9055c8 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp @@ -1303,10 +1303,12 @@ CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId, return mlir::Value{}; } case AMDGPU::BI__builtin_amdgcn_alignbit: { - cgm.errorNYI(expr->getSourceRange(), - std::string("unimplemented AMDGPU builtin call: ") + - getContext().BuiltinInfo.getName(builtinId)); - return mlir::Value{}; + mlir::Value arg0 = emitScalarExpr(expr->getArg(0)); + mlir::Value arg1 = emitScalarExpr(expr->getArg(1)); + mlir::Value arg2 = emitScalarExpr(expr->getArg(2)); + mlir::Location loc = getLoc(expr->getExprLoc()); + mlir::Type ty = convertType(expr->getType()); + return cir::FshrOp::create(builder, loc, ty, arg0, arg1, arg2).getResult(); } case AMDGPU::BI__builtin_amdgcn_fence: { // The scope uses AMDGPU spelling on every target, like mapScopeToSPIRV. diff --git a/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip b/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip index 180f632b5050b..6b2384c7cf1d8 100644 --- a/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip +++ b/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip @@ -409,6 +409,15 @@ __device__ void test_lerp(unsigned int* out, unsigned int src0, unsigned int src *out = __builtin_amdgcn_lerp(src0, src1, src2); } +// CIR-LABEL: @_Z13test_alignbitPjjjj +// CIR: cir.fshr {{.*}} : !u32i +// LLVM: define{{.*}} void @_Z13test_alignbitPjjjj +// LLVM: call{{.*}} i32 @llvm.fshr.i32(i32 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}) +__device__ void test_alignbit(unsigned int* out, unsigned int src0, unsigned int src1, + unsigned int src2) { + *out = __builtin_amdgcn_alignbit(src0, src1, src2); +} + // CIR-LABEL: @_Z9test_ubfePjjjj // CIR: cir.call_llvm_intrinsic "amdgcn.ubfe" {{.*}} : (!u32i, !u32i, !u32i) -> !u32i // LLVM: define{{.*}} void @_Z9test_ubfePjjjj `````````` </details> https://github.com/llvm/llvm-project/pull/242166 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
