summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-07-17 20:22:38 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-07-17 20:22:38 +0000
commit914a59cad825f322ef10273327e708fe5eb78283 (patch)
tree3878f684cc227582940e418b011b91d36c98c347 /llvm/unittests
parenta0858e2f20c84df1be9d0add9b726996bbe395a4 (diff)
downloadbcm5719-llvm-914a59cad825f322ef10273327e708fe5eb78283.tar.gz
bcm5719-llvm-914a59cad825f322ef10273327e708fe5eb78283.zip
GlobalISel: Handle more cases for widenScalar of G_MERGE_VALUES
Use an anyext to the requested type for the leftover operand to produce a slightly wider type, and then truncate the final merge. I have another implementation almost ready which handles arbitrary widens, but I think it produces worse code in this example (which I think is 90% due to not folding redundant copies or folding out implicit_def users), so I wanted to add this as a baseline first. llvm-svn: 366366
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
index 2ba95ab0826..608c0ddf084 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
@@ -9,6 +9,10 @@
#include "GISelMITest.h"
+using namespace LegalizeActions;
+using namespace LegalizeMutations;
+using namespace LegalityPredicates;
+
namespace {
class DummyGISelObserver : public GISelChangeObserver {
@@ -900,4 +904,34 @@ TEST_F(GISelMITest, WidenScalarBuildVector) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}
+TEST_F(GISelMITest, LowerMergeValues) {
+ if (!TM)
+ return;
+
+ const LLT S24 = LLT::scalar(24);
+ const LLT S9 = LLT::scalar(9);
+ const LLT S3 = LLT::scalar(3);
+
+ DefineLegalizerInfo(A, {
+ getActionDefinitionsBuilder(G_UNMERGE_VALUES)
+ .widenScalarIf(typeIs(1, LLT::scalar(3)), changeTo(1, LLT::scalar(9)));
+ });
+
+ AInfo Info(MF->getSubtarget());
+ DummyGISelObserver Observer;
+ LegalizerHelper Helper(*MF, Info, Observer, B);
+ B.setInsertPt(*EntryMBB, EntryMBB->end());
+
+ // 24 = 3 3 3 3 3 3 3 3
+ // => 9
+ //
+ // This can do 2 merges for the first parts, but has 2 leftover operands.
+ SmallVector<Register, 7> MergeOps;
+ for (int I = 0; I != 8; ++I)
+ MergeOps.push_back(B.buildConstant(S3, I).getReg(0));
+
+ auto Merge = B.buildMerge(S24, MergeOps);
+ EXPECT_EQ(LegalizerHelper::LegalizeResult::UnableToLegalize,
+ Helper.lower(*Merge, 1, S9));
+}
} // namespace
OpenPOWER on IntegriCloud