[PATCH] D80416: [RFC][OpenCL] Set fp contract flag on -cl-mad-enable

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 22 03:00:58 PDT 2020


Anastasia added a comment.

In D80416#2050250 <https://reviews.llvm.org/D80416#2050250>, @arsenm wrote:

> The langref wording makes me think this isn't quite right. This depends on your definition of floating point contraction. I've always assumed it meant allow FMA, potentially increasing precision. Is contracting into something less precise allowed?


I don't see anywhere it says that contraction is for higher precision only. If I check the LLVM language manual `fast` flag implies `contract` which is what we are setting with `-cl-fast-relaxed-math` known to result in lower accuracy.

> If not, that's stricter / the opposite of what -cl-mad-enable implies. My interpretation of the CL spec description would be to use fmuladd with an afn flag (although that still can allow for increasing precision)

Currently `fmuladd` is produced with `LangOptions::FPM_On` that is used with FP_CONTRACT pragma. If I look at the documentation `LangOptions::FPM_Fast` is serving the same  purpose just allowing more cases to be contracted (i.e. across statements). Hence due to this it sets contract flag rather than emitting intrinsic directly providing more freedom to the backend to optimise and combine fused computations.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80416/new/

https://reviews.llvm.org/D80416





More information about the cfe-commits mailing list