[llvm] r347094 - [LegalizeVectorOps] After custom legalizing an extending load or a truncating store, make sure the custom code is also legal.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 13:04:59 PST 2018


Author: ctopper
Date: Fri Nov 16 13:04:58 2018
New Revision: 347094

URL: http://llvm.org/viewvc/llvm-project?rev=347094&view=rev
Log:
[LegalizeVectorOps] After custom legalizing an extending load or a truncating store, make sure the custom code is also legal.

For example, on X86 we emit a sign_extend_vector_inreg from LowerLoad and without sse4.1 this node will need further legalization. Previously this sign_extend_vector_inreg was being custom lowered during DAG legalization instead of vector op legalization.

Unfortunately, this doesn't seem to matter for the output of any existing lit tests.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp?rev=347094&r1=347093&r2=347094&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Fri Nov 16 13:04:58 2018
@@ -244,7 +244,11 @@ SDValue VectorLegalizer::LegalizeOp(SDVa
         if (SDValue Lowered = TLI.LowerOperation(Result, DAG)) {
           assert(Lowered->getNumValues() == Op->getNumValues() &&
                  "Unexpected number of results");
-          Changed = Lowered != Result;
+          if (Lowered != Result) {
+            // Make sure the new code is also legal.
+            Lowered = LegalizeOp(Lowered);
+            Changed = true;
+          }
           return TranslateLegalizeResults(Op, Lowered);
         }
         LLVM_FALLTHROUGH;
@@ -266,7 +270,11 @@ SDValue VectorLegalizer::LegalizeOp(SDVa
         return TranslateLegalizeResults(Op, Result);
       case TargetLowering::Custom: {
         SDValue Lowered = TLI.LowerOperation(Result, DAG);
-        Changed = Lowered != Result;
+        if (Lowered != Result) {
+          // Make sure the new code is also legal.
+          Lowered = LegalizeOp(Lowered);
+          Changed = true;
+        }
         return TranslateLegalizeResults(Op, Lowered);
       }
       case TargetLowering::Expand:




More information about the llvm-commits mailing list