summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-02-07 17:25:51 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-02-07 17:25:51 +0000
commit91be65be656072a68b51a8c4e7bb751ea475d896 (patch)
treed3c63504f16de21d3e4e6dce07fa57b024c084c1 /llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
parentbae220ce9c2b774e06bb0e811ccb0d7a018c526f (diff)
downloadbcm5719-llvm-91be65be656072a68b51a8c4e7bb751ea475d896.tar.gz
bcm5719-llvm-91be65be656072a68b51a8c4e7bb751ea475d896.zip
GlobalISel: Try to make legalize rules more useful for vectors
Mostly keep the existing functions on scalars, but add versions which also operate based on the vector element size. llvm-svn: 353430
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
index 33228abcfb8..fcbecf90a84 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
@@ -26,14 +26,30 @@ LegalizeMutation LegalizeMutations::changeTo(unsigned TypeIdx,
};
}
-LegalizeMutation LegalizeMutations::widenScalarToNextPow2(unsigned TypeIdx,
- unsigned Min) {
+LegalizeMutation LegalizeMutations::changeElementTo(unsigned TypeIdx,
+ unsigned FromTypeIdx) {
return [=](const LegalityQuery &Query) {
- unsigned NewSizeInBits =
- 1 << Log2_32_Ceil(Query.Types[TypeIdx].getSizeInBits());
- if (NewSizeInBits < Min)
- NewSizeInBits = Min;
- return std::make_pair(TypeIdx, LLT::scalar(NewSizeInBits));
+ const LLT OldTy = Query.Types[TypeIdx];
+ const LLT NewTy = Query.Types[FromTypeIdx];
+ return std::make_pair(TypeIdx, OldTy.changeElementType(NewTy));
+ };
+}
+
+LegalizeMutation LegalizeMutations::changeElementTo(unsigned TypeIdx,
+ LLT NewEltTy) {
+ return [=](const LegalityQuery &Query) {
+ const LLT OldTy = Query.Types[TypeIdx];
+ return std::make_pair(TypeIdx, OldTy.changeElementType(NewEltTy));
+ };
+}
+
+LegalizeMutation LegalizeMutations::widenScalarOrEltToNextPow2(unsigned TypeIdx,
+ unsigned Min) {
+ return [=](const LegalityQuery &Query) {
+ const LLT Ty = Query.Types[TypeIdx];
+ unsigned NewEltSizeInBits =
+ std::max(1u << Log2_32_Ceil(Ty.getScalarSizeInBits()), Min);
+ return std::make_pair(TypeIdx, Ty.changeElementSize(NewEltSizeInBits));
};
}
OpenPOWER on IntegriCloud