From 89b090e51edfa2bd595a992a73c4faf429f45265 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 11 Sep 2009 00:34:46 +0000 Subject: Reapply r81171 with a fix: don't try to use i64 when it isn't legal. llvm-svn: 81492 --- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index f0c70861843..15c2140b86c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -615,12 +615,27 @@ FastISel::SelectFNeg(User *I) { unsigned OpReg = getRegForValue(BinaryOperator::getFNegArgument(I)); if (OpReg == 0) return false; - // Twiddle the sign bit with xor. + // 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; - unsigned ResultReg = FastEmit_ri_(VT.getSimpleVT(), ISD::XOR, OpReg, - UINT64_C(1) << (VT.getSizeInBits()-1), - VT.getSimpleVT()); + EVT IntVT = EVT::getIntegerVT(I->getContext(), VT.getSizeInBits()); + if (!TLI.isTypeLegal(IntVT)) + return false; + + unsigned IntReg = FastEmit_r(VT.getSimpleVT(), IntVT.getSimpleVT(), + ISD::BIT_CONVERT, OpReg); + if (IntReg == 0) + return false; + + unsigned IntResultReg = FastEmit_ri_(IntVT.getSimpleVT(), ISD::XOR, IntReg, + UINT64_C(1) << (VT.getSizeInBits()-1), + IntVT.getSimpleVT()); + if (IntResultReg == 0) + return false; + + ResultReg = FastEmit_r(IntVT.getSimpleVT(), VT.getSimpleVT(), + ISD::BIT_CONVERT, IntResultReg); if (ResultReg == 0) return false; -- cgit v1.2.3