Skip to content

Commit

Permalink
[NFC][clang] Replace unchecked dyn_cast with cast (#98948)
Browse files Browse the repository at this point in the history
BI__builtin_hlsl_elementwise_rcp is only invoked with a FixedVectorType
so use cast to make this clear and satisfy the static verifier.
  • Loading branch information
mikerice1969 authored Jul 16, 2024
1 parent 80d2614 commit 9454400
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18389,13 +18389,12 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
llvm_unreachable("rcp operand must have a float representation");
llvm::Type *Ty = Op0->getType();
llvm::Type *EltTy = Ty->getScalarType();
Constant *One =
Ty->isVectorTy()
? ConstantVector::getSplat(
ElementCount::getFixed(
dyn_cast<FixedVectorType>(Ty)->getNumElements()),
ConstantFP::get(EltTy, 1.0))
: ConstantFP::get(EltTy, 1.0);
Constant *One = Ty->isVectorTy()
? ConstantVector::getSplat(
ElementCount::getFixed(
cast<FixedVectorType>(Ty)->getNumElements()),
ConstantFP::get(EltTy, 1.0))
: ConstantFP::get(EltTy, 1.0);
return Builder.CreateFDiv(One, Op0, "hlsl.rcp");
}
case Builtin::BI__builtin_hlsl_elementwise_rsqrt: {
Expand Down

0 comments on commit 9454400

Please sign in to comment.