<div dir="ltr"><div class="gmail_quote"><div>Hi Hal,</div><div dir="ltr"><br></div><div dir="ltr">On Sun, Oct 2, 2016 at 7:43 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tim,<br class="gmail_msg">
<br class="gmail_msg">
How, in general, are you thinking about doing this? I ask because, as you clearly know, the double-double format is formed by the sum of two double-precision numbers, and the various arithmetic operations are formed mostly in terms of double-precision arithmetic on the elements of the pairs. As a result, I suspect we really just want to store the two double-precision numbers, and essentially delegate to APFloat IEEEdouble in the implementation of the various operations.<br class="gmail_msg">
<br class="gmail_msg">
As such, one option might be that, when PPCDoubleDouble fltSemantics are selected, the exponent and sign are ignored, and we just store the data for the two double-precision floating-point numbers in the significand. We might even do this directly, by making the significand something like this:<br class="gmail_msg">
<br class="gmail_msg">
  union Significand {<br class="gmail_msg">
    integerPart part;<br class="gmail_msg">
    integerPart *parts;<br class="gmail_msg">
    APFloat *fltparts; // used for PPCDoubleDouble<br class="gmail_msg">
  } significand;<br class="gmail_msg"></blockquote><div><br></div><div>We can do this, but my concern is "what's next?". What do we do to significandParts()? It doesn't make sense to return an array of integerParts for PPCDoubleDouble. Do we examine every call site of significandParts(), and assert/dispatch on fltSemantics? Do we want to build an abstraction between APFloat and the underlying data representation? For example:</div><div><br></div><div>class APFloatPayload {</div><div>  union Significand { integerPart part; integerPart *parts; } significand;</div><div>  int exponent;</div><div><br></div><div>public:<br></div><div>  // *Significand() operations.</div><div>};</div><div><br></div><div>class APFloat {</div><div>  fltSemantics *semantics;<br></div><div><div>  fltCategory category;</div></div><div>  APFloatPayload first;</div><div>  Optional<APFloatPayload> second;  // for PPCDoubleDouble</div><div>};</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
Thanks again,<br class="gmail_msg">
Hal<br class="gmail_msg">
<br class="gmail_msg">
----- Original Message -----<br class="gmail_msg">
> From: "Tim Shen" <<a href="mailto:timshen@google.com" class="gmail_msg" target="_blank">timshen@google.com</a>><br class="gmail_msg">
> To: <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
> Cc: <a href="mailto:resistor@mac.com" class="gmail_msg" target="_blank">resistor@mac.com</a>, "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="gmail_msg" target="_blank">hfinkel@anl.gov</a>>, "Fiona Glaser" <<a href="mailto:escha@apple.com" class="gmail_msg" target="_blank">escha@apple.com</a>>, "Stephen Canon"<br class="gmail_msg">
> <<a href="mailto:scanon@apple.com" class="gmail_msg" target="_blank">scanon@apple.com</a>>, "Eric Christopher" <<a href="mailto:echristo@gmail.com" class="gmail_msg" target="_blank">echristo@gmail.com</a>><br class="gmail_msg">
> Sent: Friday, September 30, 2016 4:43:12 PM<br class="gmail_msg">
> Subject: [PPC, APFloat] Add full PPCDoubleDouble to APFloat<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> I have found some internal test failures due to the wrong constant<br class="gmail_msg">
> folding on ppc_fp128.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> As documented in APFloat::PPCDoubleDouble, APFloat doesn't support<br class="gmail_msg">
> PowerPC double-double correctly <<br class="gmail_msg">
> <a href="https://github.com/llvm-mirror/llvm/blob/492acdd450bcdf9837494d6da029ed064f14fc33/lib/Support/APFloat.cpp#L74" rel="noreferrer" class="gmail_msg" target="_blank">https://github.com/llvm-mirror/llvm/blob/492acdd450bcdf9837494d6da029ed064f14fc33/lib/Support/APFloat.cpp#L74</a><br class="gmail_msg">
> >.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> To support this, we need to add a second tuple of (sign, exponent,<br class="gmail_msg">
> significand) to APFloat. I wonder where should I start to change, so<br class="gmail_msg">
> that it's less hacky? I certainly expect refactoring to come. :)<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Thanks!<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Hal Finkel<br class="gmail_msg">
Lead, Compiler Technology and Programming Languages<br class="gmail_msg">
Leadership Computing Facility<br class="gmail_msg">
Argonne National Laboratory<br class="gmail_msg">
</blockquote></div></div>