summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
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
commitb539ea5393215100720a2269b4cd5523593cd90a (patch)
tree34443783986fb4580399d3fb56d9a0647a3dbe0e /llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
parentcb75f61c1df33836942731bc2006d5fcfe366f4e (diff)
downloadbcm5719-llvm-b539ea5393215100720a2269b4cd5523593cd90a.tar.gz
bcm5719-llvm-b539ea5393215100720a2269b4cd5523593cd90a.zip
[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 llvm-svn: 306806
Diffstat (limited to 'llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
index 882df5f2521..0e881759656 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/llvm/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)));
+}
}
OpenPOWER on IntegriCloud