[clang] [AMDGPU] Lower __builtin_amdgcn_read_exec_hi to use amdgcn_ballot (PR #69567)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 25 00:39:09 PDT 2023
================
@@ -7995,15 +7995,24 @@ enum SpecialRegisterAccessKind {
Write,
};
+// Generates the IR for __builtin_read_exec_*.
+// Lowers the builtin to amdgcn_ballot intrinsic.
static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
llvm::Type *RegisterType,
- llvm::Type *ValueType) {
+ llvm::Type *ValueType, bool isExecHi) {
CodeGen::CGBuilderTy &Builder = CGF.Builder;
CodeGen::CodeGenModule &CGM = CGF.CGM;
- llvm::Type *ResultType = CGF.ConvertType(E->getType());
- Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
+ Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)});
+
+ if (isExecHi) {
+ Value *C1 = llvm::ConstantInt::get(ValueType, 32);
+ Value *Rt2 = Builder.CreateLShr(Call, C1);
----------------
arsenm wrote:
There's a CreateLShr overload that takes the constant integer, you don't need the ConstantInt::get
https://github.com/llvm/llvm-project/pull/69567
More information about the cfe-commits
mailing list