<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 8/8/13 10:40 AM, Michael Ilseman
      wrote:<br>
    </div>
    <blockquote
      cite="mid:11AC32DD-BC9B-4832-8367-DD84051DB0B8@apple.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      I believe we were under the impression that InstCombine, as a
      canonicalized/optimizer, should not increase code size but only
      reduce it.
      <div><br>
      </div>
      <div>Minor aside, but you don't need all of fast-math for the IR,
        just the "arcp" flag, which allows for replacement of division
        with reciprocal-multiply.<br>
      </div>
    </blockquote>
    <br>
    I vaguely remember we are not quite happy with the arcp relax rank
    because the it is not very relax, while <br>
    the the reciprocal is very imprecise. I guess we are better off
    using unsafe-math to guard such xform?<br>
    <br>
    <blockquote
      cite="mid:11AC32DD-BC9B-4832-8367-DD84051DB0B8@apple.com"
      type="cite">
      <div>
        <div><br>
          <div>
            <div>On Aug 8, 2013, at 10:21 AM, Shuxin Yang <<a
                moz-do-not-send="true"
                href="mailto:shuxin.llvm@gmail.com">shuxin.llvm@gmail.com</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <blockquote type="cite">
              <meta content="text/html; charset=ISO-8859-1"
                http-equiv="Content-Type">
              <div bgcolor="#FFFFFF" text="#000000"> I remember why I
                didn't implement this rule in Instcombine. It add one
                instruction. So, <br>
                this xform should be driven by a redundancy eliminator
                if you care code size. <br>
                <br>
                <div class="moz-cite-prefix">On 8/8/13 10:13 AM, Shuxin
                  Yang wrote:<br>
                </div>
                <blockquote cite="mid:5203D1A3.9090506@gmail.com"
                  type="cite">
                  <meta content="text/html; charset=ISO-8859-1"
                    http-equiv="Content-Type">
                  I did few transformation in Instruction
                  *InstCombiner::visitFDiv() in an attempt to remove
                  some divs. <br>
                  I may miss this case.  If you need to implement this
                  rule, it is better done in Instcombine than in DAG
                  combine. <br>
                  Doing such xform early expose the redundancy of 1/y,
                  which have positive impact to neighboring code, <br>
                  while DAG combine is bit blind. <br>
                  <br>
                  You should be very careful, reciprocal is very very
                  very imprecise transformation. Sometimes you will see
                  big different<br>
                  with and without this xform. <br>
                  <br>
                  <div class="moz-cite-prefix">On 8/8/13 9:25 AM, Chad
                    Rosier wrote:<br>
                  </div>
                  <blockquote
cite="mid:CAMo3wbRcDnCo5EYaawWDOMCaAFz5BP9iD=kN8D4My3MRHVX4gw@mail.gmail.com"
                    type="cite">I would like to transform X/Y ->
                    X*1/Y.  Specifically, I would like to convert:<br>
                    <br>
                    define void @t1a(double %a, double %b, double %d) {<br>
                    entry:<br>
                      %div = fdiv fast double %a, %d<br>
                      %div1 = fdiv fast double %b, %d<br>
                      %call = tail call i32 @foo(double %div, double
                    %div1)<br>
                      ret void<br>
                    }<br>
                    <br>
                    to:<br>
                    <br>
                    define void @t1b(double %a, double %b, double %d) {<br>
                    entry:<br>
                      %div = fdiv fast double 1.000000e+00, %d<br>
                      %mul = fmul fast double %div, %a<br>
                      %mul1 = fmul fast double %div, %b<br>
                      %call = tail call i32 @foo(double %mul, double
                    %mul1)<br>
                      ret void<br>
                    }<br>
                    <br>
                    Is such a transformation best done as a
                    (target-specific) DAG combine?<br>
                    <br>
                    A similar instcombine already exists for the
                    X/C->X*1/C case (see the CvtFDivConstToReciprocal
                    function in InstCombineMlDivRem.cpp), but I don't
                    believe the above can be done as an instcombine as
                    it creates a new instruction (in addition to
                    replacing the original).  Also, I only want to
                    perform the transformation if there are multiple
                    uses of 1/Y (like in my test case).  Otherwise, the
                    transformation replaces a fdiv with a fdiv+fmul
                    pair, which I doubt would be profitable.<br>
                    <br>
                    FWIW, I'm also pretty sure this combine requires
                    -fast-math.<br>
                    <br>
                    Can someone point me in the right direction?<br>
                    <br>
                     Thanks,<br>
                      Chad<br>
                    <br>
                    <fieldset class="mimeAttachmentHeader"></fieldset>
                    <br>
                    <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
                  </blockquote>
                  <br>
                </blockquote>
                <br>
              </div>
              _______________________________________________<br>
              LLVM Developers mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>
                      <a moz-do-not-send="true"
                href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>
              <a moz-do-not-send="true"
                href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>