Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -8938,16 +8938,22 @@ SDValue MFFS = DAG.getNode(PPCISD::MFFS, dl, {MVT::f64, MVT::Other}, Chain); Chain = MFFS.getValue(1); - // Save FP register to stack slot - int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false); - SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT); - Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo()); - - // Load FP Control Word from low 32 bits of stack slot. - SDValue Four = DAG.getConstant(4, dl, PtrVT); - SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four); - SDValue CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo()); - Chain = CWD.getValue(1); + SDValue CWD; + if (Subtarget.isPPC64()) { + CWD = DAG.getNode(ISD::TRUNCATE, dl, MVT::i32, + DAG.getNode(ISD::BITCAST, dl, MVT::i64, MFFS)); + } else { + // Save FP register to stack slot + int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false); + SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT); + Chain = DAG.getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo()); + + // Load FP Control Word from low 32 bits of stack slot. + SDValue Four = DAG.getConstant(4, dl, PtrVT); + SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four); + CWD = DAG.getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo()); + Chain = CWD.getValue(1); + } // Transform as necessary SDValue CWD1 = Index: llvm/test/CodeGen/PowerPC/frounds.ll =================================================================== --- llvm/test/CodeGen/PowerPC/frounds.ll +++ llvm/test/CodeGen/PowerPC/frounds.ll @@ -42,7 +42,7 @@ ; PPC64LE: # %bb.0: # %entry ; PPC64LE-NEXT: mffs 0 ; PPC64LE-NEXT: stfd 0, -16(1) -; PPC64LE-NEXT: lwz 3, -12(1) +; PPC64LE-NEXT: lwz 3, -16(1) ; PPC64LE-NEXT: not 4, 3 ; PPC64LE-NEXT: clrlwi 3, 3, 30 ; PPC64LE-NEXT: rlwinm 4, 4, 31, 31, 31 @@ -54,8 +54,7 @@ ; DM-LABEL: foo: ; DM: # %bb.0: # %entry ; DM-NEXT: mffs 0 -; DM-NEXT: stfd 0, -16(1) -; DM-NEXT: lwz 3, -12(1) +; DM-NEXT: mffprd 3, 0 ; DM-NEXT: not 4, 3 ; DM-NEXT: clrlwi 3, 3, 30 ; DM-NEXT: rlwinm 4, 4, 31, 31, 31