<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 03/14/2017 01:16 PM, vivek pandya
wrote:<br>
</div>
<blockquote
cite="mid:CAHYgpoLyOCR9uHgrzrxL5dGBEC1OA+LRBG3WGOwbYGT5vH+bhw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Mar 14, 2017 at 9:59 PM,
vivek pandya <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:vivekvpandya@gmail.com" target="_blank">vivekvpandya@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span class="gmail-">On Tue,
Mar 14, 2017 at 7:19 PM, Hal Finkel <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px
0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><span>
<p><br>
</p>
<div
class="gmail-m_-893470938952784482m_4013586522218816313moz-cite-prefix">On
03/14/2017 07:16 AM, vivek pandya wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hello Hal,
<div>setCondCodeAction(expand) for un
ordered comparison generates
semantically wrong code for me for
example SETUNE gets converted to SETOE
that causes infinite loops.</div>
</div>
</blockquote>
<br>
</span> Can you please explain what is
happening? It sounds like a bug we should fix.<span><br>
<br>
</span></div>
</blockquote>
</span>
<div>I don't think it is LLVM bug but I am missing
some thing or I have not implemented something
related properly.</div>
<div>But I will experiment it with and let you my
findings.</div>
<span class="gmail-">
<blockquote class="gmail_quote" style="margin:0px
0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><span>
<blockquote type="cite">
<div dir="ltr">
<div><br>
</div>
<div>What is ideal place where I can
convert unordered comparison to un
comparison + OR + ordered comparison ?</div>
<div>Can I do it by adding required
SDNodes ?</div>
<div>for example I am trying to do it in
LowerBR_CC as shown below:</div>
<div>
<div> getFPCCtoMBCC(CC,TCC);</div>
<div> TargetCC =
DAG.getConstant(TCC, dl, MVT::i8);</div>
<div> Flag =
DAG.getNode(XXXISD::FCMP, dl,
MVT::Glue, LHS, RHS,</div>
<div>
TargetCC);</div>
<div> if (isUnordered) {</div>
<div> TCC = XXX::COND_UN;</div>
<div> TargetCC =
DAG.getConstant(TCC, dl, MVT::i8);</div>
<div> SDValue UnComp =
DAG.getNode(XXX::FCMP, dl,
MVT::Glue, LHS, RHS,</div>
<div>
TargetCC);</div>
<div> Flag = DAG.getNode(ISD::OR,
dl, MVT::Glue, Flag, UnComp);</div>
<div> }</div>
</div>
<div>but here I can't OR 2 MVT::Glue
value.</div>
<div>How can I compare results of two
fcmp SDValue objs?</div>
</div>
</blockquote>
<br>
</span> If your FCMP node sets some register,
you'd need to read it (DAG.getCopyFromReg).</div>
</blockquote>
</span></div>
</div>
</div>
</blockquote>
<div>Hey Hal,</div>
<div>I have few questions here,</div>
<div>Do you here mean FCMP sets any physical register ?</div>
</div>
</div>
</div>
</blockquote>
<br>
Yes.<br>
<br>
<blockquote
cite="mid:CAHYgpoLyOCR9uHgrzrxL5dGBEC1OA+LRBG3WGOwbYGT5vH+bhw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div> Because as per my understanding getCopyFromReg()
requires a reg operand to copy from. </div>
<div>What if it set some virtual register? Then how to use
getCopyFromReg() method?</div>
</div>
</div>
</div>
</blockquote>
<br>
You wouldn't. If your FCMP node sets a virtual register, then it
should be one of the return values of the node (i.e. there should be
a some value type (MVT::i8 or whatever) in the value-type list for
the FCMP node).<br>
<br>
-Hal<br>
<br>
<blockquote
cite="mid:CAHYgpoLyOCR9uHgrzrxL5dGBEC1OA+LRBG3WGOwbYGT5vH+bhw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div><br>
</div>
<div>getCopyFromReg() requires a Chain operand so I have to
make FCMP both Chain and Glue (by using <a
moz-do-not-send="true" class="gmail-code"
href="http://llvm.org/docs/doxygen/html/structllvm_1_1SDVTList.html"
title="This represents a list of ValueType's that has
been intern'd by a SelectionDAG."
style="font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253);color:rgb(70,101,162);text-decoration:none">SDVTList</a><span
style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253)">
VTs = </span><a moz-do-not-send="true"
class="gmail-code"
href="http://llvm.org/docs/doxygen/html/classllvm_1_1SelectionDAG.html#a196c23d6cb4d768d037970f1f35bbf66"
title="Return an SDVTList that represents the list of
values specified."
style="font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253);color:rgb(70,101,162);text-decoration:none">getVTList</a><span
style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253)">(</span><a
moz-do-not-send="true" class="gmail-code"
href="http://llvm.org/docs/doxygen/html/classllvm_1_1MVT.html#afd69b4f2dff97a2d7c0192cc769ef50ca62a222acce6360abd2726719fabc2797"
style="font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253);color:rgb(70,101,162);text-decoration:none">MVT::Other</a><span
style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253)">,
</span><a moz-do-not-send="true" class="gmail-code"
href="http://llvm.org/docs/doxygen/html/classllvm_1_1MVT.html#afd69b4f2dff97a2d7c0192cc769ef50ca59a1908cf136662bcfdc11ed49515ca9"
style="font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253);color:rgb(70,101,162);text-decoration:none">MVT::Glue</a><span
style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253)">))</span> right
?</div>
<div><br>
</div>
<div>Sincerely,</div>
<div>Vivek</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div>Ok I will see some examples for
getCopyFromReg().</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Vivek </div>
<div>
<div class="gmail-h5">
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><span
class="gmail-m_-893470938952784482HOEnZb"><font
color="#888888"><br>
<br>
-Hal</font></span>
<div>
<div class="gmail-m_-893470938952784482h5"><br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Please provide some guidance.</div>
<div><br>
</div>
<div>Sincerely,</div>
<div>Vivek</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Mar
9, 2017 at 10:29 PM, vivek pandya
<span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:vivekvpandya@gmail.com"
target="_blank">vivekvpandya@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div>
<div
class="gmail-m_-893470938952784482m_4013586522218816313h5">On
Thu, Mar 9, 2017 at
9:35 PM, Hal Finkel <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span>
wrote:<br>
<blockquote
class="gmail_quote"
style="margin:0px
0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div
bgcolor="#FFFFFF">
<div>
<div
class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101h5">
<p><br>
</p>
<div
class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-cite-prefix">On
02/25/2017
03:06 AM,
vivek pandya
via llvm-dev
wrote:<br>
</div>
<blockquote
type="cite">
<div dir="ltr">
<div>Note:
Question is
written after
describing
what I have
coded.<br>
</div>
<div><br>
</div>
<div>Hello
LLVMDevs,</div>
<div><br>
</div>
<div>I am
trying to
impliment
floating point
comparsion for
an
architecture
which</div>
<div>supports
following type
of floating
point
comparision if
FPU is
available:</div>
<div>fcmp.un
--> true if
one of the
operand is NaN</div>
<div><a
moz-do-not-send="true"
href="http://fcmp.lt" target="_blank">fcmp.lt</a> --> ordered less
than, if any
input NaN then
return false</div>
<div>fcmp.eq
--> ordered
equal, if any
input NaN then
return false</div>
<div>fcmp.le
--> ordered
less equal, if
any input NaN
then return
false</div>
<div><a
moz-do-not-send="true"
href="http://fcmp.gt" target="_blank">fcmp.gt</a> --> ordered grater
than, if any
input NaN then
return false</div>
<div><a
moz-do-not-send="true"
href="http://fcmp.ne" target="_blank">fcmp.ne</a> --> ordered not
equal, if any
input NaN then
return true</div>
<div><a
moz-do-not-send="true"
href="http://fcmp.ge" target="_blank">fcmp.ge</a> --> ordered grater
equal, if any
input NaN then
return false</div>
<div><br>
</div>
<div>When FPU
is not present
I need to
generate a
library call,</div>
<div><br>
</div>
<div>so I have
added
following code
in LowerBR_CC
function in
XXXISelLowering.cpp</div>
<div><br>
</div>
<div>const
XXXSubtarget
&STI =
static_cast<const
XXXSubtarget&></div>
<div>
(DAG.getSubtarget());</div>
<div> XXXCC::CondCodes
TCC;</div>
<div> getFPCCtoXXCC(CC,TCC);</div>
<div> TargetCC
=
DAG.getConstant(TCC,
dl, MVT::i8);</div>
<div> if
(STI.useHardFloat())
{</div>
<div> // if
fcmp
instruction is
available use
it</div>
<div>
SDValue Flag
=
DAG.getNode(XXXISD::FCMP,
dl, MVT::Glue,
LHS, RHS,</div>
<div>
TargetCC);</div>
<div> return
DAG.getNode(XXXISD::BR_CC, dl, Op.getValueType(),</div>
<div>
Chain,
Dest,
TargetCC,
Flag);</div>
<div> }</div>
<div> else {</div>
<div> //
else generate
library call</div>
<div>
DAG.getTargetLoweringInfo().s<wbr>oftenSetCCOperands(DAG,
MVT::f32, LHS,
RHS,</div>
<div>
CC, dl);</div>
<div><br>
</div>
<div>
SDValue Flag
=
DAG.getNode(XXXISD::CMP,
dl, MVT::Glue,
LHS, RHS);</div>
<div><br>
</div>
<div> if
(!RHS.getNode())
{</div>
<div> RHS
=
DAG.getConstant(0,
dl,
LHS.getValueType());</div>
<div>
TargetCC =
DAG.getConstant(XXXCC::COND_NE<wbr>,
dl, MVT::i8);</div>
<div> }</div>
<div> return
DAG.getNode(XXXISD::BR_CC, dl, MVT::Other,</div>
<div>
Chain,
Dest,
TargetCC,
Flag);</div>
<div> }</div>
<div><br>
</div>
<div> and code
for
getFPCCtoXXCC()
is as
following:</div>
<div><br>
</div>
<div> static
void
getFPCCtoXXCC(ISD::CondCode
CC,
XXXCC::CondCodes
&CondCode)
{</div>
<div> switch
(CC) {</div>
<div>
default:</div>
<div>
llvm_unreachable("Unknown
FP
condition!");</div>
<div> case
ISD::SETEQ:</div>
<div> case
ISD::SETOEQ:</div>
<div>
CondCode =
XXXCC::COND_E;</div>
<div>
break;</div>
<div> case
ISD::SETGT:</div>
<div> case
ISD::SETOGT:</div>
<div>
CondCode =
XXXCC::COND_GT;</div>
<div>
break;</div>
<div> case
ISD::SETGE:</div>
<div> case
ISD::SETOGE:</div>
<div>
CondCode =
XXXCC::COND_GE;</div>
<div>
break;</div>
<div> case
ISD::SETOLT:</div>
<div> case
ISD::SETLT:</div>
<div>
CondCode =
XXXCC::COND_LT;</div>
<div>
break;</div>
<div> case
ISD::SETOLE:</div>
<div> case
ISD::SETLE:</div>
<div>
CondCode =
XXXCC::COND_LE;</div>
<div>
break;</div>
<div> case
ISD::SETONE:</div>
<div> case
ISD::SETNE:</div>
<div>
CondCode =
XXXCC::COND_NE;</div>
<div>
break;</div>
<div> case
ISD::SETUO:</div>
<div>
CondCode =
XXXCC::COND_UN;</div>
<div>
break;</div>
<div> case
ISD::SETO:</div>
<div> case
ISD::SETUEQ:</div>
<div> case
ISD::SETUGT:</div>
<div> case
ISD::SETUGE:</div>
<div> case
ISD::SETULT:</div>
<div> case
ISD::SETULE:</div>
<div> case
ISD::SETUNE:</div>
<div> CC
=
getSetCCInverse(CC,false);</div>
<div>
getFPCCtoMBCC(CC,CondCode);</div>
<div>
break;</div>
<div> }</div>
<div>}</div>
<div><br>
</div>
<div> I am
generating
wrong code
when using
floating point
library call
for </div>
<div>comparions.
For the
following
simple case:</div>
<div>float
branchTest(float
a, float b) {</div>
<div><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>float
retVal;<span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span></div>
<div><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>if
(a == b) {<span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span></div>
<div><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>retVal
= a / b +
22.34;</div>
<div><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>}</div>
<div><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>return
retVal;</div>
<div>}</div>
<div>I am
getting:</div>
<div>brlid<span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>r15,__nesf2</div>
<div>nop</div>
<div>beqi<span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>r3,.LBB0_2
; r3 is return
regsiter</div>
<div><br>
</div>
<div>Now I
want to
understand
difference
between three
different
version of
Condition</div>
<div>Codes for
same operation
and how
according to
my target I
should handle
them.</div>
<div>For
example let's
consider
SETNE, SETONE
and SETUNE so
for my
architecture </div>
<div>I think
for floating
point all
three are same</div>
</div>
</blockquote>
<br>
</div>
</div>
No, they're not
the same. Please
see:<br>
<br>
<a
moz-do-not-send="true"
class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-txt-link-freetext"
href="http://llvm.org/docs/LangRef.html#id290" target="_blank">http://llvm.org/docs/LangRef.h<wbr>tml#id290</a><br>
<br>
which explains the
difference between
SETONE (one) and
SETUNE (une).
Regarding how
SETNE is
interpreted for
FP, see the
comment in the
definition of
CondCode in
include/llvm/CodeGen/ISDOpcode<wbr>s.h
which explains,
"// Don't care
operations:
undefined if the
input is a nan.".<br>
<br>
To support the
unordered
comparisons, if
your FPU has only
ordered
comparisons, then
you might need to
do the underlying
comparison, and a
NaN check, and
then OR the
results. I think
that using
setCondCodeAction
will cause the
expansions for the
hardware-unsupported variants to happen for you.<br>
<br>
-Hal<br>
</div>
</blockquote>
<div> </div>
</div>
</div>
<div>Thanks Hal for the
guidance !</div>
<span
class="gmail-m_-893470938952784482m_4013586522218816313HOEnZb"><font
color="#888888">
<div><br>
</div>
<div>-Vivek </div>
</font></span>
<div>
<div
class="gmail-m_-893470938952784482m_4013586522218816313h5">
<blockquote
class="gmail_quote"
style="margin:0px
0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div
bgcolor="#FFFFFF">
<br>
<blockquote
type="cite"><span>
<div dir="ltr">
<div> so do I
need to use </div>
<div>getSetCCInverse()
? Also when I
look at the
code of </div>
<div>TargetLowering::softenSetCCOpe<wbr>rands
I see that for
some condition
code it uses</div>
<div>getSetCCInverse()
and also I am
not able to
understand the
way it groups </div>
<div>condition
code in switch
case for
example :</div>
<div> case
ISD::SETEQ:</div>
<div> case
ISD::SETOEQ:</div>
<div> LC1 =
(VT ==
MVT::f32) ?
RTLIB::OEQ_F32
:</div>
<div>
(VT ==
MVT::f64) ?
RTLIB::OEQ_F64
:
RTLIB::OEQ_F128;</div>
<div>
break;</div>
<div> case
ISD::SETNE:</div>
<div> case
ISD::SETUNE:</div>
<div> LC1 =
(VT ==
MVT::f32) ?
RTLIB::UNE_F32
:</div>
<div>
(VT ==
MVT::f64) ?
RTLIB::UNE_F64
:
RTLIB::UNE_F128;</div>
<div>
break;</div>
<div>here why
SETNE and
SETUNE is
considered
same, why
SETONE is
considered </div>
<div>differently.
Is there any
guideline to
lower
conditional
code properly?</div>
<div><br>
</div>
<div>Sincerely,</div>
<div>Vivek</div>
<div><br>
</div>
</div>
<br>
<fieldset
class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072mimeAttachmentHeader"></fieldset>
<br>
</span>
<pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
</font></span></pre><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
</font></span></blockquote><span class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
<pre class="gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</font></span></div>
</blockquote></div></div></div>
</div></div>
</blockquote></div>
</div>
</blockquote>
<pre class="gmail-m_-893470938952784482m_4013586522218816313moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre></div></div></div></blockquote></div></div></div>
</div></div>
</blockquote></div>
</div></div>
</blockquote>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre></body></html>