use -0.0 when creating an fneg instruction

Backends recognize (-0.0 - X) as the canonical form for fneg
and produce better code. Eg, ppc64 with 0.0:

   lis r2, ha16(LCPI0_0)
   lfs f0, lo16(LCPI0_0)(r2)
   fsubs f1, f0, f1
   blr

vs. -0.0:

   fneg f1, f1
   blr

Differential Revision: http://reviews.llvm.org/D6723



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224583 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel 2014-12-19 16:44:08 +00:00
parent 01b07d541b
commit 7c5fa50875
2 changed files with 2 additions and 2 deletions

View File

@ -759,7 +759,7 @@ Value *FAddCombine::createFSub(Value *Opnd0, Value *Opnd1) {
}
Value *FAddCombine::createFNeg(Value *V) {
Value *Zero = cast<Value>(ConstantFP::get(V->getType(), 0.0));
Value *Zero = cast<Value>(ConstantFP::getZeroValueForNegation(V->getType()));
Value *NewV = createFSub(Zero, V);
if (Instruction *I = dyn_cast<Instruction>(NewV))
createInstPostProc(I, true); // fneg's don't receive instruction numbers.

View File

@ -93,7 +93,7 @@ define float @fold9(float %f1, float %f2) {
ret float %t3
; CHECK-LABEL: @fold9(
; CHECK: fsub fast float 0.000000e+00, %f2
; CHECK: fsub fast float -0.000000e+00, %f2
}
; Let C3 = C1 + C2. (f1 + C1) + (f2 + C2) => (f1 + f2) + C3 instead of