[llvm] 4b45295 - [LegalizeTypes] In SoftenFloatRes_FP_EXTEND, move the check for input already being promoted above the check for fp16 converting to something other than fp32.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 12:48:34 PST 2019


Author: Craig Topper
Date: 2019-12-11T12:48:08-08:00
New Revision: 4b452952fed75b87c6768bfc1f558d312c645b02

URL: https://github.com/llvm/llvm-project/commit/4b452952fed75b87c6768bfc1f558d312c645b02
DIFF: https://github.com/llvm/llvm-project/commit/4b452952fed75b87c6768bfc1f558d312c645b02.diff

LOG: [LegalizeTypes] In SoftenFloatRes_FP_EXTEND, move the check for input already being promoted above the check for fp16 converting to something other than fp32.

The fp16 to larger than fp32 inserts an extend that need to
re-legalized if fp16 is promoted. But if we check for fp16
promotion first, then we can avoid emiting the fp_extend all
together.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 686bdbef9a63..4bea8716b0ca 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -466,6 +466,14 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(SDNode *N) {
 
   SDValue Chain = IsStrict ? N->getOperand(0) : SDValue();
 
+  if (getTypeAction(Op.getValueType()) == TargetLowering::TypePromoteFloat) {
+    Op = GetPromotedFloat(Op);
+    // If the promotion did the FP_EXTEND to the destination type for us,
+    // there's nothing left to do here.
+    if (Op.getValueType() == N->getValueType(0))
+      return BitConvertToInteger(Op);
+  }
+
   // There's only a libcall for f16 -> f32, so proceed in two stages. Also, it's
   // entirely possible for both f16 and f32 to be legal, so use the fully
   // hard-float FP_EXTEND rather than FP16_TO_FP.
@@ -479,15 +487,6 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(SDNode *N) {
     }
   }
 
-  if (getTypeAction(Op.getValueType()) == TargetLowering::TypePromoteFloat) {
-    Op = GetPromotedFloat(Op);
-    // If the promotion did the FP_EXTEND to the destination type for us,
-    // there's nothing left to do here.
-    if (Op.getValueType() == N->getValueType(0)) {
-      return BitConvertToInteger(Op);
-    }
-  }
-
   RTLIB::Libcall LC = RTLIB::getFPEXT(Op.getValueType(), N->getValueType(0));
   assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_EXTEND!");
   TargetLowering::MakeLibCallOptions CallOptions;


        


More information about the llvm-commits mailing list