<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’ve uploaded the first set of patches for this. They should fix LTO for fused multiply-and-add. -ffp-contract=fast is now translated into a new FMF called contract. <div class=""><br class=""></div><div class=""><ol class="">
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">llvm: [IR] Add AllowContract to FastMathFlags <a href="https://reviews.llvm.org/D31164" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31164</span></a></li>
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">llvm: [SDAG] Add AllowContract to SNodeFlags <a href="https://reviews.llvm.org/D31165" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31165</span></a></li>
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">clang: Encapsulate FPOptions and use it consistently <a href="https://reviews.llvm.org/D31166" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31166</span></a></li>
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">clang: Use FPContractModeKind universally <a href="https://reviews.llvm.org/D31167" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31167</span></a></li>
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">clang: Set FMF on -ffp-contract=fast rather than <a href="https://reviews.llvm.org/D31168" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31168</span></a></li>
<li style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class="">llvm: [DAGCombiner] Initial support for the fast-math flag contract <a href="https://reviews.llvm.org/D31169" class=""><span style="color: #e4af0a" class="">https://reviews.llvm.org/D31169</span></a></li>
</ol><div class="">DAGCombine support for fused subtract and then the pragma we discussed is coming up later. Please help to review what I have so far.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Adam</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 16, 2017, at 5:20 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
</p>
<div class="moz-cite-prefix">On 03/16/2017 06:23 PM, Adam Nemet
wrote:<br class="">
</div>
<blockquote cite="mid:FD4A0C01-E39A-463B-B7B4-F17AEAEB1C43@apple.com" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Mar 16, 2017, at 4:04 PM, Adam Nemet via
cfe-dev <<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" class="">
<div class=""><br class="Apple-interchange-newline">
On Mar 16, 2017, at 3:25 PM, Hal Finkel <<a moz-do-not-send="true" href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
</p>
<div class="moz-cite-prefix">On 03/16/2017 04:13 PM,
Adam Nemet wrote:<br class="">
</div>
<blockquote cite="mid:2A017F54-ED5D-4B62-A774-CCCED49E2206@apple.com" type="cite" class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Mar 15, 2017, at 2:51 PM,
Adam Nemet <<a moz-do-not-send="true" href="mailto:anemet@apple.com" class="">anemet@apple.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<blockquote type="cite" class="" style="font-family: Helvetica; font-size:
12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div class=""><br class="Apple-interchange-newline">
On Mar 15, 2017, at 2:30 PM, Hal Finkel
<<a moz-do-not-send="true" href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
</p>
<div class="moz-cite-prefix">On
03/15/2017 04:05 PM, Adam Nemet
wrote:<br class="">
</div>
<blockquote cite="mid:C5B19D31-4651-4840-B9AC-C4F6FD1BD04D@apple.com" type="cite" class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Mar 15, 2017,
at 2:00 PM, Hal Finkel <<a moz-do-not-send="true" href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
</p>
<div class="moz-cite-prefix">On
03/15/2017 01:47 PM, Adam
Nemet wrote:<br class="">
</div>
<blockquote cite="mid:E74F3BD7-4CF9-4CF7-8657-BC4776A71D03@apple.com" type="cite" class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Mar
15, 2017, at 11:36
AM, Mehdi Amini <<a moz-do-not-send="true" href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="" style="word-wrap:
break-word;
-webkit-nbsp-mode:
space;
-webkit-line-break:
after-white-space;"><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On
Mar 15, 2017,
at 10:13 AM,
Hal Finkel via
cfe-dev <<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="moz-cite-prefix" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);"><br class="Apple-interchange-newline">
On 03/15/2017
12:10 PM, Adam
Nemet via
llvm-dev
wrote:<br class="">
</div>
<blockquote cite="mid:FAB9D19D-F8F0-4364-BE54-5203FFB1295E@apple.com" type="cite" class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
orphans: auto;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
widows: auto;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">Relevant
to this
discussion is <a moz-do-not-send="true" href="http://bugs.llvm.org/show_bug.cgi?id=25721" class="">http://bugs.llvm.org/show_bug.cgi?id=25721</a> (-ffp-contract=fast
does not work
with LTO). I
am working on
adding
function
attributes for
fp-contract=fast which should fix this.</blockquote>
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">Great!</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">A
function
attribute
would be a
strict
improvement
over today:
LLVM can’t do
contraction
today. But
actually I’m
not sure if it
is the long
term right
choice:
attributes
don’t combine
well with
inlining for
instance. You
mentioned FMF
earlier, why
don’t we have
a FMF to allow
contraction?</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">OK, I
thought that the
prerequisite for that
was a fast-math pragma
which I don’t think is
something we have (I
want to be able to
specify contract=fast
on smaller granularity
than module). But now
that I think more
about, we should be
able to turn a user
function attribute
into FMF in the
front-end which is the
most flexible.<span class="Apple-converted-space"> </span><br class="">
</div>
</div>
</blockquote>
<br class="">
I agree, a FMF is the way to
go and we can then control
it with the pragma. We can
use the STDC FP_CONTRACT
pragma for contraction;</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Just to confirm, do
you mean to introduce a “fast”
option to the pragma, e.g.:</div>
<div class=""><br class="">
</div>
<div class="">#pragma STDC
FP_CONTRACT FAST</div>
</div>
</blockquote>
<br class="">
That's a good point. If we don't add
something like this, then we'd be able
to turn the fast mode off with the
pragma, but then not be able to turn
it back on ;)<br class="">
<br class="">
So, yes, except that I'm somewhat
hesitant to invade the 'STDC' space
with vendor extensions. If we
generally introduce a pragma to
control FMFs, maybe we should just use
that instead? I don't have a clear
idea on the syntax, but for example,
if we had some pragma that let us do<br class="">
<br class="">
#pragma clang fast_math or #pragma
clang fast_math nnan(off) contract(on)
or whatever then we could use that.
What do you think?<br class="">
</div>
</div>
</blockquote>
<div class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;"><br class="">
</div>
<div class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">That
looks great; it nicely matches the
internal representation. Let me take a
stab at this.</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Thinking more about this, I am
back to thinking that a function attribute is
the better solution for this than FMF, at
least before inlining.</div>
<div class=""><br class="">
</div>
<div class="">Consider the standard example
where we want this to trigger: an overloaded
addition and multiplier operator for a vector
class.</div>
<div class=""><br class="">
</div>
<div class="">In this case, we want the fadd and
the fmul in the inlined functions to have the
FMF as well but we don’t necessarily want to
mark the overloaded operators with the pragma;
we may be only comfortable contracting at this
call site.</div>
<div class=""><br class="">
</div>
<div class="">You don’t have this problem if you
mark the containing function FP-contractable.
Effectively what we want is to outline the
block within the pragma into a function and
tag it with the attribute.</div>
<div class=""><br class="">
</div>
<div class="">During inlining we can still
transform the function attribute into FMF.</div>
<div class=""><br class="">
</div>
<div class="">So I think I am going back to
implementing fp-contract=fast as a function
attribute as the first step unless there are
any objections.</div>
</div>
</blockquote>
<br class="">
Are you saying this works because we don't block
inlining when functions attributes don't match or
update the function attributes to be more
conservative when inlining? This is specifically one
of the issues we were avoiding by using FMFs.
Frankly, the same issue comes up with other
fast-math properties, and I don't see why we should
handle this differently. I think that I'd prefer you
stick with the new flag.<br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">OK, so in the example:</div>
<div class=""><br class="">
</div>
<div class="">#pragma clang fast_math contract_fast(on)</div>
<div class=""> vect v1 = v2 * v3 + v4;</div>
<div class="">#pragma clang fast_math contract_fast(off)</div>
<div class=""><br class="">
</div>
<div class="">where all the operands are vectors with the
typical implementation for the overload operators, we
wouldn’t fp-contract unless the operator definitions use
contract_fast too?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">I guess it’s the conservative thing to do since those
functions may have non-contractable operations.</div>
</div>
</blockquote>
<br class="">
Exactly; the problem is that this is the desirable behavior in some
circumstances and undesirable in others, but I think that doing the
conservative thing is the most self-consistent choice (and also
allows users the most powerful fine-grained control).<br class="">
<br class="">
Thanks again,<br class="">
Hal<br class="">
<br class="">
<blockquote cite="mid:FD4A0C01-E39A-463B-B7B4-F17AEAEB1C43@apple.com" type="cite" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Adam</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<div class=""><br class="">
</div>
<div class="">Adam</div>
<div class=""><br class="">
</div>
<blockquote type="cite" class="">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><br class="">
-Hal<br class="">
<br class="">
<blockquote cite="mid:2A017F54-ED5D-4B62-A774-CCCED49E2206@apple.com" type="cite" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Adam</div>
<div class=""><br class="">
</div>
<blockquote type="cite" class="">
<div class="">
<div class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;"><br class="">
</div>
<div class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">Adam</div>
<br class="" style="font-family: Helvetica;
font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<blockquote type="cite" class="" style="font-family: Helvetica; font-size:
12px; font-style: normal;
font-variant-caps: normal; font-weight:
normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class=""><br class="">
-Hal<br class="">
<br class="">
<blockquote cite="mid:C5B19D31-4651-4840-B9AC-C4F6FD1BD04D@apple.com" type="cite" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Adam</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class="">I
also think that having a
"fast math" pragma is also a
good idea (the fact that we
can currently only specify
fast-math settings on a
translation-unit level is
somewhat problematic).<br class="">
<br class="">
<blockquote cite="mid:E74F3BD7-4CF9-4CF7-8657-BC4776A71D03@apple.com" type="cite" class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">
<div class="" style="word-wrap:
break-word;
-webkit-nbsp-mode:
space;
-webkit-line-break:
after-white-space;">
<div class="">
<div class=""><br class="">
</div>
<div class="">Also,
IIUC, the
function
attribute as
well as a FMF
wouldn’t apply
to the “ON”
setting but
only to the
“FAST” mode
(no way to
distinguish
source level
statement in
llvm IR).</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
<br class="">
Right. We still have the
existing fmuladd intrinsic
method for dealing with the
"ON" setting.<br class="">
<br class="">
<blockquote cite="mid:E74F3BD7-4CF9-4CF7-8657-BC4776A71D03@apple.com" type="cite" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">Yes.</div>
<div class=""><br class="">
</div>
<div class="">Adam</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="" style="word-wrap:
break-word;
-webkit-nbsp-mode:
space;
-webkit-line-break:
after-white-space;">
<div class="">
<div class=""><br class="">
</div>
<div class="">— </div>
<div class="">Mehdi</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<blockquote cite="mid:FAB9D19D-F8F0-4364-BE54-5203FFB1295E@apple.com" type="cite" class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
orphans: auto;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
widows: auto;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<div class=""><br class="">
</div>
<div class="">Also
now that we
have backend
optimization
remarks, I am
planning to
report missed
optimization
when we can’t
fuse FMAs due
“fast” not
being on.
This will
show up in the
opt-viewer.
Then the user
can opt in
either with
the
command-line
switch or the
new function
attribute.</div>
</blockquote>
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">That
seems useful.</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">Thanks
again,</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">Hal</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<blockquote cite="mid:FAB9D19D-F8F0-4364-BE54-5203FFB1295E@apple.com" type="cite" class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
orphans: auto;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
widows: auto;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<div class=""><br class="">
</div>
<div class="">Adam<br class="">
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On
Mar 15, 2017,
at 6:27 AM,
Renato Golin
via cfe-dev
<<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Folks,<br class="">
<br class="">
I've been
asking around
people about
the state of
FP contract,
which<br class="">
seems to be
"on" but it's
not really
behaving like
it, at least
not as<br class="">
I would
expect:<br class="">
<br class="">
int foo(float
a, float b,
float c) {
return a*b+c;
}<br class="">
<br class="">
$ clang
-target
aarch64-linux-gnu
-O2 -S fma.c
-ffp-contract=on
-o -<br class="">
(...)<br class="">
fmul s0, s0,
s1<br class="">
fadd s0, s0,
s2<br class="">
(...)<br class="">
<br class="">
$ clang
-target
aarch64-linux-gnu
-O2 -S fma.c
-ffp-contract=fast
-o -<br class="">
(...)<br class="">
fmadd s0, s0,
s1, s2<br class="">
(...)<br class="">
<br class="">
I'm not sure
this works in
Fortran
either, but
defaulting to
"on" when<br class="">
(I believe)
the language
should allow
contraction
and not doing
it is<br class="">
not a good
default.<br class="">
<br class="">
i haven't
worked out
what would be
necessary to
make it work
on a<br class="">
case-by-case
basis (what
kinds of
fusions does C
allow?) to
make sure<br class="">
we don't do
all or
nothing, but
if we don't
want to start
that<br class="">
conversation
now, then I'd
recommend we
just turn it
all the way to
11<br class="">
(like GCC) and
let people
turn it off if
they really
mean it.<br class="">
<br class="">
The rationale
is that:<br class="">
<br class="">
* Contracted
operations
increase
precision
(less rounding
steps)<br class="">
* It performs
equal or
faster on all
architectures
I know (true
everywhere?)<br class="">
* Users
already expect
that
(certainly,
GCC users do)<br class="">
* Makes us
look good on
benchmarks :)<br class="">
<br class="">
A recent
SPEC2k6
comparison
Linaro did for
AArch64,
enabling<br class="">
-ffp-contract=fast took the edge of GCC in a number of cases and in<br class="">
some of them
made them
comparable in
performance.
So, any
reasons not<br class="">
to?<br class="">
<br class="">
If we go with
it, we need to
first finish
the job that
Sebastian was<br class="">
dong on the
test-suite,
then just turn
it on by
default. A
second<br class="">
stage would be
to add
tests/benchmarks
that
explicitly
test FP<br class="">
precision, so
that we have
some extra
guarantee that
we're doing
the<br class="">
right thing.<br class="">
<br class="">
Opinions?<br class="">
<br class="">
cheers,<br class="">
--renato<br class="">
_______________________________________________<br class="">
cfe-dev
mailing list<br class="">
<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre class="" wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<pre class="moz-signature" cols="72" style="font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">_______________________________________________</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255); float:
none; display:
inline
!important;">cfe-dev
mailing list</span><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
orphans: auto;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
widows: auto;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">cfe-dev@lists.llvm.org</a><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
<a moz-do-not-send="true" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
orphans: auto;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
widows: auto;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="" style="font-family:
Helvetica;
font-size:
12px;
font-style:
normal;
font-variant-caps:
normal;
font-weight:
normal;
letter-spacing:
normal;
text-align:
start;
text-indent:
0px;
text-transform:
none;
white-space:
normal;
word-spacing:
0px;
-webkit-text-stroke-width:
0px;
background-color:
rgb(255, 255,
255);">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</blockquote>
<br class="">
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</div>
</blockquote>
</div>
<br class="">
</blockquote>
<br class="">
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br class="">
</blockquote>
<br class="">
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</div>
</blockquote>
</div>
<br class="" style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">cfe-dev mailing list</span><br style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true" href="mailto:cfe-dev@lists.llvm.org" style="font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px;" class="">cfe-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></div>
</blockquote>
</div>
<br class="">
</blockquote>
<br class="">
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</div></blockquote></div><br class=""></div></div></body></html>