<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi, Qiu Chaofan,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Can you please upload the patch to reviews.llvm.org? It's much easier for me to review patches there (see <a href="https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface" class="OWAAutoLink" id="LPlnk398478" previewremoved="true">https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface</a> for
instructions).</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks again,</p>
<p style="margin-top:0;margin-bottom:0">Hal</p>
<br>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="Signature">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory</div>
</span></font></div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Qiu Chaofan <qcf.ibm@outlook.com><br>
<b>Sent:</b> Friday, August 9, 2019 4:34 AM<br>
<b>To:</b> Finkel, Hal J. <hfinkel@anl.gov>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] Improve iteration of estimating divisions</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hal,<br>
<br>
Here is the patch. Thanks.<br>
<br>
Regards,<br>
Qiu Chaofan<br>
<br>
________________________________________<br>
From: Finkel, Hal J. <hfinkel@anl.gov><br>
Sent: August 9, 2019 0:58 AM<br>
To: Qiu Chaofan; llvm-dev@lists.llvm.org<br>
Subject: Re: 回复: [llvm-dev] [RFC] Improve iteration of estimating divisions<br>
<br>
I think that it's certainly worth posting a patch and then we can evaluate it.<br>
<br>
<br>
Thanks again,<br>
<br>
Hal<br>
<br>
<br>
Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
<br>
<br>
________________________________<br>
From: Qiu Chaofan <qcf.ibm@outlook.com><br>
Sent: Thursday, August 8, 2019 11:47 AM<br>
To: Finkel, Hal J. <hfinkel@anl.gov>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
Subject: 回复: [llvm-dev] [RFC] Improve iteration of estimating divisions<br>
<br>
Hal,<br>
<br>
Yes, speed is an important factor of making dicision. Here I just put the numerator into estimation, so it won't add any more instructions. A simple benchmark below keeps the same running time between the demo and current master:<br>
<br>
```<br>
float fdiv(unsigned int a, unsigned int b) {<br>
return (float)a / (float)b;<br>
}<br>
<br>
float m;<br>
<br>
__attribute__((noinline)) void foo() {<br>
m = 0.0;<br>
}<br>
<br>
int main() {<br>
for (int i = 1; i < 1000000; ++i)<br>
for (int j = 1; j < 30000; ++j) {<br>
m = fdiv(i, j);<br>
foo();<br>
}<br>
}<br>
```<br>
<br>
Regards,<br>
Qiu Chaofan<br>
<br>
________________________________________<br>
发件人: Finkel, Hal J. <hfinkel@anl.gov><br>
发送时间: 2019年8月7日 4:04<br>
收件人: 邱 超凡; llvm-dev@lists.llvm.org<br>
主题: Re: [llvm-dev] [RFC] Improve iteration of estimating divisions<br>
<br>
<br>
On 8/6/19 12:20 AM, 邱 超凡 via llvm-dev wrote:<br>
> Hi there, I notice that our current implementation of fast division transformation (turn `a / b` into `a * (1/b)`) is worse in precision compared with GCC. Like this case in ppc64le:<br>
><br>
> float fdiv(unsigned int a, unsigned int b) {<br>
> return (float)a / (float)b;<br>
> }<br>
><br>
> Result of Clang -Ofast is 41A00001 (in Hex), while GCC produces 41A00000 which is the same as no optimizations opened.<br>
><br>
> Currently, DAGCombiner uses `BuildReciprocalEstimate` to calculate the reciprocal (`1/b`) first and multiply it with `a`. But if we put the operand `a` into iterations in the estimate function, the result would be better.<br>
><br>
> Patching such a change may break several existing test cases in different platforms since it’s target-independent code. So any suggestions are welcome. Thanks.<br>
<br>
<br>
Test cases can be changed if the result is universally better, and<br>
alternatively, we can introduce a way for the target to control the<br>
behavior (e.g., how we choose between buildSqrtNROneConst and<br>
buildSqrtNRTwoConst). What's the effect on performance?<br>
<br>
-Hal<br>
<br>
<br>
><br>
> Regards,<br>
> Qiu Chaofan<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> llvm-dev@lists.llvm.org<br>
> <a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7C%7Cdbff2450e5bb4b63e5f108d71aa94e7f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637007186791161795&sdata=LWVNeuqNP0FRnckeZQk03JwJcuBJgsKZh%2Fb%2BddLrhhU%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7C%7Cc2abcac5871c4d53a5df08d71c219e51%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637008803028883849&sdata=RqzLfRlaeUZJzkeeVwzeDJ%2Be%2BjVlgINNs7wlQGWkzN8%3D&reserved=0" id="LPlnk318044" class="OWAAutoLink" previewremoved="true">
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7C%7Cdbff2450e5bb4b63e5f108d71aa94e7f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637007186791161795&sdata=LWVNeuqNP0FRnckeZQk03JwJcuBJgsKZh%2Fb%2BddLrhhU%3D&reserved=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7C%7Cc2abcac5871c4d53a5df08d71c219e51%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637008803028883849&sdata=RqzLfRlaeUZJzkeeVwzeDJ%2Be%2BjVlgINNs7wlQGWkzN8%3D&reserved=0</a>><br>
<br>
--<br>
Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>