Skip to content

Commit f47b06a

Browse files
committed
clang: Remove upstream diff in read_exec builtins
At some point 970569b was reverted on amd-staging, and seems to have been "restored" in 4adf616, but with code that does not match the current upstream version Change-Id: Ibe728107f929370f8f3178f3143292f70a414c07
1 parent 845edee commit f47b06a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8992,27 +8992,24 @@ enum SpecialRegisterAccessKind {
89928992
Write,
89938993
};
89948994

8995+
// Generates the IR for __builtin_read_exec_*.
8996+
// Lowers the builtin to amdgcn_ballot intrinsic.
89958997
static Value *EmitAMDGCNBallotForExec(CodeGenFunction &CGF, const CallExpr *E,
89968998
llvm::Type *RegisterType,
89978999
llvm::Type *ValueType, bool isExecHi) {
89989000
CodeGen::CGBuilderTy &Builder = CGF.Builder;
89999001
CodeGen::CodeGenModule &CGM = CGF.CGM;
90009002

9001-
llvm::Type *ResultType = CGF.ConvertType(E->getType());
9002-
llvm::Value *Call;
9003-
Function *F;
9003+
Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
9004+
llvm::Value *Call = Builder.CreateCall(F, {Builder.getInt1(true)});
9005+
90049006
if (isExecHi) {
9005-
F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {RegisterType});
9006-
Call = Builder.CreateCall(F, {Builder.getInt1(true)});
9007-
Value *C1 = llvm::ConstantInt::get(ValueType, 32);
9008-
Value *Rt2 = Builder.CreateLShr(Call, C1);
9009-
Value *Rt3 = Builder.CreateTruncOrBitCast(Rt2, CGF.Int32Ty);
9010-
return Rt3;
9011-
} else {
9012-
F = CGM.getIntrinsic(Intrinsic::amdgcn_ballot, {ResultType});
9013-
Call = Builder.CreateCall(F, {Builder.getInt1(true)});
9014-
return Call;
9007+
Value *Rt2 = Builder.CreateLShr(Call, 32);
9008+
Rt2 = Builder.CreateTrunc(Rt2, CGF.Int32Ty);
9009+
return Rt2;
90159010
}
9011+
9012+
return Call;
90169013
}
90179014

90189015
// Generates the IR for the read/write special register builtin,

0 commit comments

Comments
 (0)