I believe the advice that Owen gave me was that if it's simple enough, we should do it in both places. (Feel free to chime in if I'm misquoting you, Owen.)<br><br>Performing the transformation early as an InstCombine can expose additional opportunities to optimize code. The purpose of the redundant DAGCombine would be to catch the case where the optimization is exposed by another DAG combine. And as Jim also pointed out, the DAG combine has the benefit of target-specific knowledge.<br>
<br>I agree, this will require quite a bit of testing.<br><br> Chad<br><br><div class="gmail_quote">On Thu, Aug 8, 2013 at 1:13 PM, Shuxin Yang <span dir="ltr"><<a href="mailto:shuxin.llvm@gmail.com" target="_blank">shuxin.llvm@gmail.com</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">
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><div><div class="h5">
<br>
<div>On 8/8/13 9:25 AM, Chad Rosier wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">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></fieldset>
<br>
</div></div><div class="im"><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</div></blockquote>
<br>
</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br>