[LLVMdev] Clarifying FMA-related TargetOptions

Hal Finkel hfinkel at anl.gov
Wed Feb 8 10:56:01 PST 2012

On Wed, 2012-02-08 at 10:46 -0800, Owen Anderson wrote:
> On Feb 8, 2012, at 10:42 AM, Hal Finkel wrote:
> > In my experience, users of numerical codes expect that the compiler will
> > use FMA instructions where it can, unless specifically asked to avoid
> > doing so by the user. Even though this can sometimes produce a different
> > result (*almost* always a better one), the performance gain is too large
> > to be ignored by default. I highly recommend that we continue to enable
> > FMA instruction-generation by default (as is the current practice, not
> > only here, but in most vendor compilers with which I am familiar). We
> > should also implement the FP_CONTRACT pragma, but that is another
> > matter.
> The caveat I would add to this is that, when I tried enabling FMA-by-default on an ARM target, I saw a large number of testcases in the LLVM test suite that either failed their output comparisons, crashed, or failed to terminate (!!!).  That seems pretty scary to me.

That is quite scary. I could obviously be wrong, but I would suspect
that something else is going on here. Either there is a bug in the FMA
patch, or the patch is triggering a bug elsewhere. Although I've
certainly seen cases where enabling FMA changes some numerical results
(slightly), crashing and failing to terminate in a large number of cases
seems like another issue. Most code just does not depend on exact
floating-point cancelation in a way that impacts loop termination
conditions, memory indexing, etc.


> --Owen

Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory

More information about the llvm-dev mailing list