From fba1fbb9c7367990a0561a36dbf600fc51847246 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 9 Jan 2020 12:54:16 -0500 Subject: [PATCH] GlobalISel: Don't assert on MoreElements creating vectors If the original type was a scalar, it should be valid to add elements to turn it into a vector. Tests included with following legalization change. --- llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp index f897f9c..02f6b39 100644 --- a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp @@ -128,24 +128,26 @@ static bool mutationIsSane(const LegalizeRule &Rule, switch (Rule.getAction()) { case FewerElements: - case MoreElements: { if (!OldTy.isVector()) return false; - + LLVM_FALLTHROUGH; + case MoreElements: { + // MoreElements can go from scalar to vector. + const unsigned OldElts = OldTy.isVector() ? OldTy.getNumElements() : 1; if (NewTy.isVector()) { if (Rule.getAction() == FewerElements) { // Make sure the element count really decreased. - if (NewTy.getNumElements() >= OldTy.getNumElements()) + if (NewTy.getNumElements() >= OldElts) return false; } else { // Make sure the element count really increased. - if (NewTy.getNumElements() <= OldTy.getNumElements()) + if (NewTy.getNumElements() <= OldElts) return false; } } // Make sure the element type didn't change. - return NewTy.getScalarType() == OldTy.getElementType(); + return NewTy.getScalarType() == OldTy.getScalarType(); } case NarrowScalar: case WidenScalar: { -- 2.7.4