Author: Craig Topper Date: 2021-01-15T11:52:53-08:00 New Revision: a9e939760c6f21476109559cc3e21779bddddaff
URL: https://github.com/llvm/llvm-project/commit/a9e939760c6f21476109559cc3e21779bddddaff DIFF: https://github.com/llvm/llvm-project/commit/a9e939760c6f21476109559cc3e21779bddddaff.diff LOG: [CodeGen] Removes unwanted optimisation for TargetConstantFP This 'FIXME' popped up in the development of an out-of-tree backend. Quick fix, but first llvm upstream patch, therefore I do not have commit rights, so if approved please commit? - Test is not included as this came up in an out-of-tree backend (if required, please hint on how to test this). Patch by simveg (Simon) Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D93219 Added: Modified: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Removed: ################################################################################ diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 523895200f6a..2437b07e7d0e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -431,7 +431,6 @@ SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) { LLVM_DEBUG(dbgs() << "Optimizing float store operations\n"); // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr' - // FIXME: We shouldn't do this for TargetConstantFP's. // FIXME: move this to the DAG Combiner! Note that we can't regress due // to phase ordering between legalized code and the dag combiner. This // probably means that we need to integrate dag combiner and legalizer @@ -439,10 +438,16 @@ SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) { // We generally can't do this one for long doubles. SDValue Chain = ST->getChain(); SDValue Ptr = ST->getBasePtr(); + SDValue Value = ST->getValue(); MachineMemOperand::Flags MMOFlags = ST->getMemOperand()->getFlags(); AAMDNodes AAInfo = ST->getAAInfo(); SDLoc dl(ST); - if (ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(ST->getValue())) { + + // Don't optimise TargetConstantFP + if (Value.getOpcode() == ISD::TargetConstantFP) + return SDValue(); + + if (ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(Value)) { if (CFP->getValueType(0) == MVT::f32 && TLI.isTypeLegal(MVT::i32)) { SDValue Con = DAG.getConstant(CFP->getValueAPF(). @@ -482,7 +487,7 @@ SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) { } } } - return SDValue(nullptr, 0); + return SDValue(); } void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) { _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits