builder/llpcBuilderImplArith.cpp
// =====================================================================================================================
// Create a "cosh" operation for a scalar or vector float or half.
Create a "cosh" operation for a scalar or vector float or half.
Create a " cosh " operation for a scalar or vector float or half .
Value* BuilderImplArith::CreateCosh(
    Value*        pX,         
    const Twine&  instName)   
{
    Value* pDivLog2 = CreateFMul(pX, GetRecipLog2(pX->getType()));
    Value* pNegDivLog2 = CreateFSub(ConstantFP::get(pX->getType(), 0.0), pDivLog2);
    Value* pExp = CreateUnaryIntrinsic(Intrinsic::exp2, pDivLog2);
    Value* pExpNeg = CreateUnaryIntrinsic(Intrinsic::exp2, pNegDivLog2);
    Value* pResult = CreateFAdd(pExp, pExpNeg);
    return CreateFMul(pResult, ConstantFP::get(pX->getType(), 0.5), instName);
}
Value * BuilderImplArith :: CreateCosh ( Value * pX , const Twine & instName ) { Value * pDivLog2 = CreateFMul ( pX , GetRecipLog2 ( pX -> getType ( ) ) ) ; Value * pNegDivLog2 = CreateFSub ( ConstantFP :: get ( pX -> getType ( ) , 0.0 ) , pDivLog2 ) ; Value * pExp = CreateUnaryIntrinsic ( Intrinsic :: exp2 , pDivLog2 ) ; Value * pExpNeg = CreateUnaryIntrinsic ( Intrinsic :: exp2 , pNegDivLog2 ) ; Value * pResult = CreateFAdd ( pExp , pExpNeg ) ; return CreateFMul ( pResult , ConstantFP :: get ( pX -> getType ( ) , 0.5 ) , instName ) ; }
Create a "cosh" operation for a scalar or vector float or half.
Create a " cosh " operation for a scalar or vector float or half .
// [in] Input value X // [in] Name to give instruction(s) // (e^x + e^(-x)) / 2.0 // e^x = 2^(x * 1.442695) // 1/log(2) = 1.442695 // e^x = 2^(x*(1/log(2))) = 2^(x*1.442695))