Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Mar 2014 02:28:13 +0000
From:      "Montgomery-Smith, Stephen" <stephen@missouri.edu>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        "freebsd-numerics@freebsd.org" <freebsd-numerics@freebsd.org>
Subject:   Re: clang is almost useless for complex arithmetic
Message-ID:  <53338CB9.4030405@missouri.edu>
In-Reply-To: <20140327020802.GA15862@troutmask.apl.washington.edu>
References:  <20140326002205.GA9940@troutmask.apl.washington.edu> <53338661.7060205@missouri.edu> <20140327020802.GA15862@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 03/26/2014 09:08 PM, Steve Kargl wrote:
> On Thu, Mar 27, 2014 at 02:01:08AM +0000, Montgomery-Smith, Stephen wrote=
:
>> On 03/25/2014 07:22 PM, Steve Kargl wrote:
>>> It appears that clang developers have chosen the naive
>>> complex division algorithm, and it does not matter whether
>>> one turns CX_LIMITED_RANGE on or off.  This means that=20
>>> if one uses clang with complex types, one must be careful
>>> with the range of values allowed in complex division.  In
>>> other words, implementation of complex libm routines cannot
>>> use complex data types and must fallback to a decomposition
>>> into real and imaginary components.=20
>>
>> Could someone write a patch for clang to fix this?
>=20
> Well, I certainly hope someone writes a patch.  I don't
> know the internals of llvm/clang/compiler_rt.
>=20

I did a bit of grepping.  Could it be that the division algorithm is
contained in the file
src/contrib/llvm/tools/clang/lib/CodeGen/CGExprComplex.cpp inside the
function ComplexExprEmitter::EmitBinDiv ?

If you look at the code, it certainly looks like it is generating code
to perform complex division, and it definitely looks like they are using
the naive algorithm.  Presumably even if one didn't fully understand the
C++ used, one could do a "monkey sees - monkey does" change to the code,
and then do some tests to see if it works.

Although looking at figure 5 in http://arxiv.org/abs/1210.4539, it
becomes clear that one has to include conditional in the generated code.
 So maybe you would need a bit of guidance from someone more expert in
the clang compiler.

Stephen=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53338CB9.4030405>