Anastasia marked an inline comment as done. Anastasia added inline comments.
================ Comment at: clang/test/CodeGenOpenCL/relaxed-fpmath.cl:21 +float fused_mad(float a, float b, float c) { + // NORMAL: @llvm.fmuladd.f32 + // FAST: fmul fast float ---------------- Anastasia wrote: > Anastasia wrote: > > Anastasia wrote: > > > I don't find this behavior "NORMAL". I don't believe we should contract > > > expressions by default in OpenCL... > > I just found in table 38 of OpenCL C spec, last entry says: > > > > > > > x * y + z > > > Implemented either as a correctly rounded fma or as a multiply and an add > > > both of which are correctly rounded. > > > > In table 8 for `fma` it states: > > > > > Returns the correctly rounded floating-point representation of the sum of > > > c with the infinitely precise product of a and b. Rounding of > > > intermediate products shall not occur. > > > > > > When I check LLVM doecumentation for fmuladd it says: > > > > > is equivalent to the expression a * b + c, except that it is unspecified > > > whether rounding will be performed between the multiplication and > > > addition steps. Fusion is not guaranteed, even if the target platform > > > supports it. If a fused multiply-add is required, the corresponding > > > llvm.fma intrinsic function should be used instead. This never sets > > > errno, just as ‘llvm.fma.*’. > > > > Does this mean that rounding of an intermediate product may occur and > > therefore it is not safe to use it for OpenCL mode by default? > > > After more digging I conclude that the use of `fmuladd` for `x * y + z` > should be ok as per table 38 of OpenCL C because it allows either fused or > non-fused operation i.e. it is ok if either intermediate value is rounded or > not. I changed my mind again. This is now covered by https://reviews.llvm.org/D80440. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80416/new/ https://reviews.llvm.org/D80416 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits