diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h --- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h @@ -1040,6 +1040,8 @@ }, [=](const LegalityQuery &Query) { LLT T = Query.Types[LargeTypeIdx]; + if (T.isVector() && T.getElementType().isPointer()) + T = T.changeElementType(LLT::scalar(T.getScalarSizeInBits())); return std::make_pair(TypeIdx, T); }); } diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp --- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp @@ -241,6 +241,7 @@ const LLT v2s64 = LLT::fixed_vector(2, 64); const LLT p0 = LLT::pointer(0, 32); + const LLT v2p0 = LLT::fixed_vector(2, p0); const LLT v3p0 = LLT::fixed_vector(3, p0); const LLT v4p0 = LLT::fixed_vector(4, p0); @@ -427,6 +428,18 @@ EXPECT_ACTION(FewerElements, 0, s16, LegalityQuery(G_ADD, {LLT::scalable_vector(8, 16)})); } + + // Test minScalarEltSameAsIf + { + LegalizerInfo LI; + auto &LegacyInfo = LI.getLegacyLegalizerInfo(); + + LI.getActionDefinitionsBuilder(G_SELECT).minScalarEltSameAsIf( + all(isVector(0), isVector(1)), 1, 0); + LegacyInfo.computeTables(); + + EXPECT_ACTION(WidenScalar, 1, v2s32, LegalityQuery(G_SELECT, {v2p0, v2s1})); + } } TEST(LegalizerInfoTest, MMOAlignment) {