<div dir="ltr">Hello LLVM Developers,<div><br></div><div>Could you please provide review for following code snippet ? I would like to understand if this is correct way to generate unordered comparison when architecture natively does not support such comparison or not. Also I am facing some assertion failure but not for all cases and not for all optimization level that makes it herder to detect. I am facing :</div><div><div>clang-3.9: /home/vpandya/llvm_old/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:356: </div><div>void llvm::ScheduleDAGSDNodes::BuildSchedUnits(): Assertion `N->getNodeId() == -1 && "Node already inserted!"' failed.</div></div><div>I have explained the code which caused this assertion but I am not able to understand why it happens.</div><div><br></div><div><div>SDValue XXXTargetLowering::LowerSELECT_CC(SDValue Op,</div><div>                                             SelectionDAG &DAG) const {</div><div>  SDValue LHS    = Op.getOperand(0);</div><div>  SDValue RHS    = Op.getOperand(1);</div><div>  SDValue TrueV  = Op.getOperand(2);</div><div>  SDValue FalseV = Op.getOperand(3);</div><div>  ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(4))->get();</div><div>  SDLoc dl   (Op);</div><div><br></div><div>  SDValue TargetCC;</div><div>  MVT SVT = LHS.getSimpleValueType();</div><div>  SDValue Flag;</div><div>  const XXXSubtarget &STI = static_cast<const XXXSubtarget&></div><div>                                                (DAG.getSubtarget());</div><div>  if (SVT == MVT::f32 && STI.hasFPU() ) {</div><div>    XXXCC::CondCodes TCC;</div><div>    bool isUnordered = false;</div><div>    switch (CC) {</div><div>      case ISD::SETUEQ:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETEQ;</div><div>        break;</div><div>      case ISD::SETUNE:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETNE;</div><div>        break;</div><div>      case ISD::SETUGT:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETGT;</div><div>        break;</div><div>      case ISD::SETUGE:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETGE;</div><div>        break;</div><div>      case ISD::SETULT:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETLT;</div><div>        break;</div><div>      case ISD::SETULE:</div><div>        isUnordered = true;</div><div>        CC = ISD::SETLE;</div><div>        break;</div><div>    }</div><div>    if (CC == ISD::SETO)</div><div>      TCC = XXXCC::COND_UN;</div><div>    else</div><div>      getFPCCtoMBCC(CC,TCC); // just converts CC to Target specific code</div><div><br></div><div>      TargetCC = DAG.getConstant(TCC, dl, MVT::i32);</div><div>      // Here if I keeo MVT::Other I am facing above mentioned asserion</div><div>      // the reason for keeping this is I want to use this node as Chain node</div><div>      // in getCopyFromReg() but when I remove this still it works</div><div>      // Is this correct use of Glue and Chain type?</div><div>      SDVTList VTList = DAG.getVTList(MVT::Glue,/* MVT::Other*/);</div><div>      Flag = DAG.getNode(XXXISD::FCMP, dl, VTList, LHS, RHS,</div><div>                         TargetCC);</div><div>      //TODO: if setCondCodeAction(unorderedCom , Exapnd) works properly then we</div><div>      // do not have to do this manually</div><div>      if (isUnordered) {</div><div>      // read result of first FCMP from R18</div><div>      SDValue Reg1 = DAG.getCopyFromReg(Flag, dl, XXX::R18, MVT::i32,</div><div>                                        Flag);</div><div>      TCC = XXXCC::COND_UN;</div><div>      TargetCC = DAG.getConstant(TCC, dl, MVT::i32);</div><div>      SDValue UnComp = DAG.getNode(XXXISD::FCMP, dl,VTList, LHS, RHS,</div><div>                                   TargetCC);</div><div>      // read result of second FCMP from R18</div><div>      SDValue Reg2 = DAG.getCopyFromReg(UnComp, dl, XXX::R18, MVT::i32,</div><div>                                        UnComp);</div><div>      SDVTList VTList1 = DAG.getVTList(MVT::i32, MVT::Other);</div><div>      // OR results of both comparion if result is 1 then jump to destination</div><div>      SDValue ORV = DAG.getNode(ISD::OR, dl, MVT::i32, Reg1, Reg2);</div><div>      SDVTList VTs = DAG.getVTList(MVT::Glue,MVT::Other);</div><div>      SDValue Ops[] = {ORV, DAG.getRegister(XXX::R18,</div><div>                                            ORV.getValueType()), ORV, ORV};</div><div><br></div><div>      Flag = DAG.getNode(ISD::CopyToReg, dl, VTs,</div><div>                    makeArrayRef(Ops, ORV.getNode() ? 4 : 3));</div><div>      }</div><div>      // fcmp instruction results 0 or 1 so next instruction will be bne{i}</div><div>      // that should branch to destination</div><div>      if (CC == ISD::SETO)</div><div>        TargetCC = DAG.getConstant(XXXCC::COND_E, dl, MVT::i32);</div><div>      else</div><div>        TargetCC = DAG.getConstant(XXXCC::COND_NE, dl, MVT::i32);</div><div><br></div><div>  }</div><div>  else {</div><div>  Flag = EmitCMP(LHS, RHS, TargetCC, CC, dl, DAG);</div><div>  }</div><div>  SDVTList VTs = DAG.getVTList(Op.getValueType(), MVT::Glue);</div><div>  SDValue Ops[] = {TrueV, FalseV, TargetCC, Flag};</div><div><br></div><div>  return DAG.getNode(XXXISD::SELECT_CC, dl, VTs, Ops);</div><div>}</div></div><div><br></div><div><br></div><div>Thanks, </div><div>Vivek</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 15, 2017 at 12:13 AM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
    <p><br>
    </p>
    <div class="m_5252325239369865208moz-cite-prefix">On 03/14/2017 01:16 PM, vivek pandya
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <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 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="m_5252325239369865208gmail-">On Tue,
                      Mar 14, 2017 at 7:19 PM, Hal Finkel <span dir="ltr"><<a 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="m_5252325239369865208gmail-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="m_5252325239369865208gmail-">
                      <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></div></div>
    Yes.<span class=""><br>
    <br>
    <blockquote 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></span>
    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).<span class="HOEnZb"><font color="#888888"><br>
    <br>
     -Hal</font></span><div><div class="h5"><br>
    <br>
    <blockquote 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 class="m_5252325239369865208gmail-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" target="_blank">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 class="m_5252325239369865208gmail-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" target="_blank">getVTList</a><span style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;background-color:rgb(251,252,253)">(</span><a class="m_5252325239369865208gmail-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" target="_blank">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 class="m_5252325239369865208gmail-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" target="_blank">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="m_5252325239369865208gmail-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="m_5252325239369865208gmail-m_-893470938952784482HOEnZb"><font color="#888888"><br>
                                <br>
                                 -Hal</font></span>
                            <div>
                              <div class="m_5252325239369865208gmail-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 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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313h5">On
                                                  Thu, Mar 9, 2017 at
                                                  9:35 PM, Hal Finkel <span dir="ltr"><<a 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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101h5">
                                                          <p><br>
                                                          </p>
                                                          <div class="m_5252325239369865208gmail-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 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 href="http://fcmp.gt" target="_blank">fcmp.gt</a> --> ordered grater
                                                          than, if any
                                                          input NaN then
                                                          return false</div>
                                                          <div><a href="http://fcmp.ne" target="_blank">fcmp.ne</a> --> ordered not
                                                          equal, if any
                                                          input NaN then
                                                          return true</div>
                                                          <div><a 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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>float
                                                          retVal;<span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap">     </span></div>
                                                          <div><span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>if
                                                          (a == b) {<span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap">  </span></div>
                                                          <div><span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap">         </span>retVal
                                                          = a / b +
                                                          22.34;</div>
                                                          <div><span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>}</div>
                                                          <div><span class="m_5252325239369865208gmail-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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072gmail-Apple-tab-span" style="white-space:pre-wrap">    </span>r15,__nesf2</div>
                                                          <div>nop</div>
                                                          <div>beqi<span class="m_5252325239369865208gmail-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 class="m_5252325239369865208gmail-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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313HOEnZb"><font color="#888888">
                                                  <div><br>
                                                  </div>
                                                  <div>-Vivek </div>
                                                </font></span>
                                              <div>
                                                <div class="m_5252325239369865208gmail-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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072mimeAttachmentHeader"></fieldset>
                                                          <br>
                                                        </span>
                                                        <pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101m_-2662977842983796072moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_5252325239369865208gmail-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="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
</font></span></pre><span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="m_5252325239369865208gmail-m_-893470938952784482m_4013586522218816313m_7239601225858991101HOEnZb"><font color="#888888">
    

    <pre class="m_5252325239369865208gmail-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="m_5252325239369865208gmail-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="m_5252325239369865208moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre></div></div></div></blockquote></div><br></div></div>