Make fast-isel try ISD::FNEG before resorting to bitcasts and xors.
authorDan Gohman <gohman@apple.com>
Fri, 11 Sep 2009 00:36:43 +0000 (00:36 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 11 Sep 2009 00:36:43 +0000 (00:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81493 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/FastISel.cpp

index 15c2140b86cf3ea4aae8dd35e359d6e269752bc4..54544a4d1499eebf13fc44e4428f42f54909a196 100644 (file)
@@ -615,9 +615,17 @@ FastISel::SelectFNeg(User *I) {
   unsigned OpReg = getRegForValue(BinaryOperator::getFNegArgument(I));
   if (OpReg == 0) return false;
 
+  // If the target has ISD::FNEG, use it.
+  EVT VT = TLI.getValueType(I->getType());
+  unsigned ResultReg = FastEmit_r(VT.getSimpleVT(), VT.getSimpleVT(),
+                                  ISD::FNEG, OpReg);
+  if (ResultReg != 0) {
+    UpdateValueMap(I, ResultReg);
+    return true;
+  }
+
   // Bitcast the value to integer, twiddle the sign bit with xor,
   // and then bitcast it back to floating-point.
-  EVT VT = TLI.getValueType(I->getType());
   if (VT.getSizeInBits() > 64) return false;
   EVT IntVT = EVT::getIntegerVT(I->getContext(), VT.getSizeInBits());
   if (!TLI.isTypeLegal(IntVT))