Skip to content

Commit 17d3551

Browse files
authored
clang: Remove upstream diff in read_exec builtins (llvm#804)
2 parents d46e7ff + f47b06a commit 17d3551

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
@@ -8989,27 +8989,24 @@ enum SpecialRegisterAccessKind {
89898989
Write,
89908990
};
89918991

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

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+
90019003
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;
90129007
}
9008+
9009+
return Call;
90139010
}
90149011

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

0 commit comments

Comments
 (0)