<div dir="ltr"><div>Hi David,<br><br></div>Yes - that's the intent of this follow-on patch:<br><a href="http://reviews.llvm.org/D6731">http://reviews.llvm.org/D6731</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 19, 2014 at 10:05 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This improves things when forming fneg but what if we see fsub 0.00, %V in the IR? Shouldn't we add a canonicalization for that?</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 19, 2014 at 11:44 AM, Sanjay Patel <span dir="ltr"><<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: spatel<br>
Date: Fri Dec 19 10:44:08 2014<br>
New Revision: 224583<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224583&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224583&view=rev</a><br>
Log:<br>
use -0.0 when creating an fneg instruction<br>
<br>
Backends recognize (-0.0 - X) as the canonical form for fneg<br>
and produce better code. Eg, ppc64 with 0.0:<br>
<br>
   lis r2, ha16(LCPI0_0)<br>
   lfs f0, lo16(LCPI0_0)(r2)<br>
   fsubs f1, f0, f1<br>
   blr<br>
<br>
vs. -0.0:<br>
<br>
   fneg f1, f1<br>
   blr<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D6723" target="_blank">http://reviews.llvm.org/D6723</a><br>
<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp<br>
    llvm/trunk/test/Transforms/InstCombine/fast-math.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=224583&r1=224582&r2=224583&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=224583&r1=224582&r2=224583&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Fri Dec 19 10:44:08 2014<br>
@@ -759,7 +759,7 @@ Value *FAddCombine::createFSub(Value *Op<br>
 }<br>
<br>
 Value *FAddCombine::createFNeg(Value *V) {<br>
-  Value *Zero = cast<Value>(ConstantFP::get(V->getType(), 0.0));<br>
+  Value *Zero = cast<Value>(ConstantFP::getZeroValueForNegation(V->getType()));<br>
   Value *NewV = createFSub(Zero, V);<br>
   if (Instruction *I = dyn_cast<Instruction>(NewV))<br>
     createInstPostProc(I, true); // fneg's don't receive instruction numbers.<br>
<br>
Modified: llvm/trunk/test/Transforms/InstCombine/fast-math.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fast-math.ll?rev=224583&r1=224582&r2=224583&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fast-math.ll?rev=224583&r1=224582&r2=224583&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/InstCombine/fast-math.ll (original)<br>
+++ llvm/trunk/test/Transforms/InstCombine/fast-math.ll Fri Dec 19 10:44:08 2014<br>
@@ -93,7 +93,7 @@ define float @fold9(float %f1, float %f2<br>
   ret float %t3<br>
<br>
 ; CHECK-LABEL: @fold9(<br>
-; CHECK: fsub fast float 0.000000e+00, %f2<br>
+; CHECK: fsub fast float -0.000000e+00, %f2<br>
 }<br>
<br>
 ; Let C3 = C1 + C2. (f1 + C1) + (f2 + C2) => (f1 + f2) + C3 instead of<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>
</div></div></blockquote></div></div>