mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-13 10:36:07 +00:00
GlobalISel: Fix moreElementsToNextPow2
This was completely broken. The condition was inverted, and changed the element type for vectors of pointers. Fixes bug 40592. llvm-svn: 353069
This commit is contained in:
parent
255412e781
commit
896c7cc6eb
@ -115,8 +115,8 @@ LegalityPredicate LegalityPredicates::memSizeInBytesNotPow2(unsigned MMOIdx) {
|
||||
|
||||
LegalityPredicate LegalityPredicates::numElementsNotPow2(unsigned TypeIdx) {
|
||||
return [=](const LegalityQuery &Query) {
|
||||
const LLT &QueryTy = Query.Types[TypeIdx];
|
||||
return QueryTy.isVector() && isPowerOf2_32(QueryTy.getNumElements());
|
||||
const LLT QueryTy = Query.Types[TypeIdx];
|
||||
return QueryTy.isVector() && !isPowerOf2_32(QueryTy.getNumElements());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,11 @@ LegalizeMutation LegalizeMutations::widenScalarToNextPow2(unsigned TypeIdx,
|
||||
LegalizeMutation LegalizeMutations::moreElementsToNextPow2(unsigned TypeIdx,
|
||||
unsigned Min) {
|
||||
return [=](const LegalityQuery &Query) {
|
||||
const LLT &VecTy = Query.Types[TypeIdx];
|
||||
unsigned NewNumElements = 1 << Log2_32_Ceil(VecTy.getNumElements());
|
||||
if (NewNumElements < Min)
|
||||
NewNumElements = Min;
|
||||
return std::make_pair(
|
||||
TypeIdx, LLT::vector(NewNumElements, VecTy.getScalarSizeInBits()));
|
||||
const LLT VecTy = Query.Types[TypeIdx];
|
||||
unsigned NewNumElements =
|
||||
std::max(1u << Log2_32_Ceil(VecTy.getNumElements()), Min);
|
||||
return std::make_pair(TypeIdx,
|
||||
LLT::vector(NewNumElements, VecTy.getElementType()));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,12 @@ operator<<(std::ostream &OS, const llvm::LLT Ty) {
|
||||
OS << SS.str();
|
||||
return OS;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, const llvm::LegalizeActionStep Ty) {
|
||||
OS << "LegalizeActionStep(" << Ty.Action << ", " << Ty.TypeIdx << ", "
|
||||
<< Ty.NewType << ')';
|
||||
return OS;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -198,3 +204,37 @@ TEST(LegalizerInfoTest, SizeChangeStrategy) {
|
||||
LegalizeActionStep(Unsupported, 0, LLT::scalar(33)));
|
||||
}
|
||||
}
|
||||
|
||||
#define EXPECT_ACTION(Action, Index, Type, Query) \
|
||||
do { \
|
||||
auto A = LI.getAction(Query); \
|
||||
EXPECT_EQ(LegalizeActionStep(Action, Index, Type), A) << A; \
|
||||
} while (0)
|
||||
|
||||
TEST(LegalizerInfoTest, RuleSets) {
|
||||
using namespace TargetOpcode;
|
||||
|
||||
const LLT s32 = LLT::scalar(32);
|
||||
|
||||
const LLT v2s32 = LLT::vector(2, 32);
|
||||
const LLT v3s32 = LLT::vector(3, 32);
|
||||
const LLT v4s32 = LLT::vector(4, 32);
|
||||
|
||||
const LLT p0 = LLT::pointer(0, 32);
|
||||
const LLT v3p0 = LLT::vector(3, p0);
|
||||
const LLT v4p0 = LLT::vector(4, p0);
|
||||
|
||||
{
|
||||
LegalizerInfo LI;
|
||||
|
||||
LI.getActionDefinitionsBuilder(G_IMPLICIT_DEF)
|
||||
.legalFor({v4s32, v4p0})
|
||||
.moreElementsToNextPow2(0);
|
||||
LI.computeTables();
|
||||
|
||||
EXPECT_ACTION(Unsupported, 0, LLT(), LegalityQuery(G_IMPLICIT_DEF, {s32}));
|
||||
EXPECT_ACTION(Unsupported, 0, LLT(), LegalityQuery(G_IMPLICIT_DEF, {v2s32}));
|
||||
EXPECT_ACTION(MoreElements, 0, v4p0, LegalityQuery(G_IMPLICIT_DEF, {v3p0}));
|
||||
EXPECT_ACTION(MoreElements, 0, v4s32, LegalityQuery(G_IMPLICIT_DEF, {v3s32}));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user