[cfe-dev] Complex arithmetic ignores -ffast-math after clang r219557, serious performance regressions

Hal Finkel hfinkel at anl.gov
Thu Jul 2 14:44:35 PDT 2015


Hey Chandler,

What's the status on this? As Richard points out, we really do need to elide this runtime calls in fast-math mode. It seems like this is just as simple as conditionally restoring some pieces of code from CGExprComplex.cpp that you removed. Are there additional complications or objections to this?

 -Hal

----- Original Message -----
> From: "Richard Campbell" <rlcamp.pdx at gmail.com>
> To: cfe-dev at cs.uiuc.edu
> Sent: Thursday, June 25, 2015 1:54:10 PM
> Subject: [cfe-dev] Complex arithmetic ignores -ffast-math after clang	r219557, serious performance regressions
> 
> 
> 
> After building with clang 3.7svn recently, I saw a huge speed hit
> across much of our HPC and floating point DSP code. I looked at the
> asm output and it's riddled with calls to ___mulsc3, which is never
> inlined (preventing lots of other optimizations) and which includes
> a bunch of C99 Annex G-recommended branch conditions for range
> checks and whatnot. One of the purposes of -ffast-math has always
> been to disable these sort of checks, trusting the developer to
> ensure that they can't happen or will be handled upstream.
> 
> 
> Explicitly writing out the real and imaginary component math in one
> of my critical sections was enough to confirm that the problem lies
> here and not elsewhere. However, doing this throughout all of our
> code would be prohibitive, and of course greatly reduces the
> readability of the code and presumably the ability for future
> compilers to optimize it in a way that I haven’t though of yet.
> 
> 
> The relevant patch discussion in the mailing list is here:
> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20141006/116248.html
> and includes a comment from hfinkel also requesting that the
> libcalls be skipped in fast-math mode. From what I can see there was
> no followup on this.
> 
> 
> At the bare minimum I think these checks should be disabled within
> mulsc3 when ffast-math or the relevant subflag is enabled, and
> preferably that the library calls be skipped entirely as before, so
> that other compiler optimizations aren't prevented.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory




More information about the cfe-dev mailing list