diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-08-09 20:10:18 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-08-09 20:10:18 +0000 |
commit | ffb60901fe088950c7683e20e7c9b198695cdddc (patch) | |
tree | 3e6028336673179653aa830c2d106d65fd1ba44b /clang/lib/CodeGen/CGExprScalar.cpp | |
parent | b61346b8b0804adcf7b08326fcb026e24a4d3ba9 (diff) | |
download | bcm5719-llvm-ffb60901fe088950c7683e20e7c9b198695cdddc.tar.gz bcm5719-llvm-ffb60901fe088950c7683e20e7c9b198695cdddc.zip |
[OpenCL] Handle -cl-fp32-correctly-rounded-divide-sqrt
Let the driver pass the option to frontend. Do not set precision metadata for division instructions when this option is set. Set function attribute "correctly-rounded-divide-sqrt-fp-math" based on this option.
Differential Revision: https://reviews.llvm.org/D22940
llvm-svn: 278155
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 343d3fb5aa6..f3936873359 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2276,8 +2276,13 @@ Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) { if (Ops.LHS->getType()->isFPOrFPVectorTy()) { llvm::Value *Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div"); - if (CGF.getLangOpts().OpenCL) { - // OpenCL 1.1 7.4: minimum accuracy of single precision / is 2.5ulp + if (CGF.getLangOpts().OpenCL && + !CGF.CGM.getCodeGenOpts().CorrectlyRoundedDivSqrt) { + // OpenCL v1.1 s7.4: minimum accuracy of single precision / is 2.5ulp + // OpenCL v1.2 s5.6.4.2: The -cl-fp32-correctly-rounded-divide-sqrt + // build option allows an application to specify that single precision + // floating-point divide (x/y and 1/x) and sqrt used in the program + // source are correctly rounded. llvm::Type *ValTy = Val->getType(); if (ValTy->isFloatTy() || (isa<llvm::VectorType>(ValTy) && |