summaryrefslogtreecommitdiff
path: root/unittests/CodeGen
diff options
context:
space:
mode:
authorKristof Beyls <kristof.beyls@arm.com>2017-06-30 08:26:20 +0000
committerKristof Beyls <kristof.beyls@arm.com>2017-06-30 08:26:20 +0000
commite6f158fee49bf7c6b9dcaf0ef322f0dfb0f161ae (patch)
tree342632967e42fe0ac87530803742c6a4d5068643 /unittests/CodeGen
parentbfae62c2cbac460e01f5d4bbbaae459e17ad2437 (diff)
[GlobalISel] Make multi-step legalization work.
In r301116, a custom lowering needed to be introduced to be able to legalize 8 and 16-bit divisions on ARM targets without a division instruction, since 2-step legalization (WidenScalar from 8 bit to 32 bit, then Libcall the 32-bit division) doesn't work. This fixes this and makes this kind of multi-step legalization, where first the size of the type needs to be changed and then some action is needed that doesn't require changing the size of the type, straighforward to specify. Differential Revision: https://reviews.llvm.org/D32529 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306806 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/CodeGen')
-rw-r--r--unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
index 882df5f2521..0e881759656 100644
--- a/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -117,4 +117,23 @@ TEST(LegalizerInfoTest, MultipleTypes) {
ASSERT_EQ(L.getAction({G_PTRTOINT, 1, p0}),
std::make_pair(LegalizerInfo::Legal, p0));
}
+
+TEST(LegalizerInfoTest, MultipleSteps) {
+ using namespace TargetOpcode;
+ LegalizerInfo L;
+ LLT s16 = LLT::scalar(16);
+ LLT s32 = LLT::scalar(32);
+ LLT s64 = LLT::scalar(64);
+
+ L.setAction({G_UREM, 0, s16}, LegalizerInfo::WidenScalar);
+ L.setAction({G_UREM, 0, s32}, LegalizerInfo::Lower);
+ L.setAction({G_UREM, 0, s64}, LegalizerInfo::Lower);
+
+ L.computeTables();
+
+ ASSERT_EQ(L.getAction({G_UREM, LLT::scalar(16)}),
+ std::make_pair(LegalizerInfo::WidenScalar, LLT::scalar(32)));
+ ASSERT_EQ(L.getAction({G_UREM, LLT::scalar(32)}),
+ std::make_pair(LegalizerInfo::Lower, LLT::scalar(32)));
+}
}