@@ -8989,27 +8989,24 @@ enum SpecialRegisterAccessKind {
8989
8989
Write,
8990
8990
};
8991
8991
8992
+ // Generates the IR for __builtin_read_exec_*.
8993
+ // Lowers the builtin to amdgcn_ballot intrinsic.
8992
8994
static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
8993
8995
llvm::Type *RegisterType,
8994
8996
llvm::Type *ValueType, bool isExecHi) {
8995
8997
CodeGen::CGBuilderTy &Builder = CGF.Builder;
8996
8998
CodeGen::CodeGenModule &CGM = CGF.CGM;
8997
8999
8998
- llvm::Type *ResultType = CGF.ConvertType(E->getType() );
8999
- llvm::Value *Call;
9000
- Function *F;
9000
+ Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType} );
9001
+ llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)}) ;
9002
+
9001
9003
if (isExecHi) {
9002
- F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
9003
- Call = Builder.CreateCall(F, {Builder.getInt1(true)});
9004
- Value *C1 = llvm::ConstantInt::get(ValueType, 32);
9005
- Value *Rt2 = Builder.CreateLShr(Call, C1);
9006
- Value *Rt3 = Builder.CreateTruncOrBitCast(Rt2, CGF.Int32Ty);
9007
- return Rt3;
9008
- } else {
9009
- F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
9010
- Call = Builder.CreateCall(F, {Builder.getInt1(true)});
9011
- return Call;
9004
+ Value *Rt2 = Builder.CreateLShr(Call, 32);
9005
+ Rt2 = Builder.CreateTrunc(Rt2, CGF.Int32Ty);
9006
+ return Rt2;
9012
9007
}
9008
+
9009
+ return Call;
9013
9010
}
9014
9011
9015
9012
// Generates the IR for the read/write special register builtin,
0 commit comments