61 changes: 47 additions & 14 deletions llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"

TEST_F(GISelMITest, TestKnownBitsCst) {
TEST_F(AArch64GISelMITest, TestKnownBitsCst) {
StringRef MIRString = " %3:_(s8) = G_CONSTANT i8 1\n"
" %4:_(s8) = COPY %3\n";
setUp(MIRString);
Expand All @@ -30,7 +30,7 @@ TEST_F(GISelMITest, TestKnownBitsCst) {
EXPECT_EQ(Res.Zero.getZExtValue(), Res2.Zero.getZExtValue());
}

TEST_F(GISelMITest, TestKnownBitsCstWithClass) {
TEST_F(AArch64GISelMITest, TestKnownBitsCstWithClass) {
StringRef MIRString = " %10:gpr32 = MOVi32imm 1\n"
" %4:_(s32) = COPY %10\n";
setUp(MIRString);
Expand Down Expand Up @@ -58,7 +58,7 @@ TEST_F(GISelMITest, TestKnownBitsCstWithClass) {

// Check that we are able to track bits through PHIs
// and get the intersections of everything we know on each operand.
TEST_F(GISelMITest, TestKnownBitsCstPHI) {
TEST_F(AArch64GISelMITest, TestKnownBitsCstPHI) {
StringRef MIRString = " bb.10:\n"
" %10:_(s8) = G_CONSTANT i8 3\n"
" %11:_(s1) = G_IMPLICIT_DEF\n"
Expand Down Expand Up @@ -92,7 +92,7 @@ TEST_F(GISelMITest, TestKnownBitsCstPHI) {
// Check that we report we know nothing when we hit a
// non-generic register.
// Note: this could be improved though!
TEST_F(GISelMITest, TestKnownBitsCstPHIToNonGenericReg) {
TEST_F(AArch64GISelMITest, TestKnownBitsCstPHIToNonGenericReg) {
StringRef MIRString = " bb.10:\n"
" %10:gpr32 = MOVi32imm 3\n"
" %11:_(s1) = G_IMPLICIT_DEF\n"
Expand Down Expand Up @@ -129,7 +129,7 @@ TEST_F(GISelMITest, TestKnownBitsCstPHIToNonGenericReg) {
// here to cover the code that stops the analysis of PHIs
// earlier. In that case, we would not even look at the
// second incoming value.
TEST_F(GISelMITest, TestKnownBitsUnknownPHI) {
TEST_F(AArch64GISelMITest, TestKnownBitsUnknownPHI) {
StringRef MIRString =
" bb.10:\n"
" %10:_(s64) = COPY %0\n"
Expand Down Expand Up @@ -165,7 +165,7 @@ TEST_F(GISelMITest, TestKnownBitsUnknownPHI) {
// For now, the analysis just stops and assumes it knows nothing,
// eventually we could teach it how to properly track phis that
// loop back.
TEST_F(GISelMITest, TestKnownBitsCstPHIWithLoop) {
TEST_F(AArch64GISelMITest, TestKnownBitsCstPHIWithLoop) {
StringRef MIRString =
" bb.10:\n"
" %10:_(s8) = G_CONSTANT i8 3\n"
Expand Down Expand Up @@ -210,7 +210,7 @@ TEST_F(GISelMITest, TestKnownBitsCstPHIWithLoop) {
// on PHIs, but eventually we could teach it how to properly track
// phis that loop back without relying on the luck effect of max
// depth.
TEST_F(GISelMITest, TestKnownBitsDecreasingCstPHIWithLoop) {
TEST_F(AArch64GISelMITest, TestKnownBitsDecreasingCstPHIWithLoop) {
StringRef MIRString = " bb.10:\n"
" %10:_(s8) = G_CONSTANT i8 5\n"
" %11:_(s8) = G_CONSTANT i8 1\n"
Expand Down Expand Up @@ -243,7 +243,7 @@ TEST_F(GISelMITest, TestKnownBitsDecreasingCstPHIWithLoop) {
EXPECT_EQ(Res.Zero.getZExtValue(), Res2.Zero.getZExtValue());
}

TEST_F(GISelMITest, TestKnownBitsPtrToIntViceVersa) {
TEST_F(AArch64GISelMITest, TestKnownBitsPtrToIntViceVersa) {
StringRef MIRString = " %3:_(s16) = G_CONSTANT i16 256\n"
" %4:_(p0) = G_INTTOPTR %3\n"
" %5:_(s32) = G_PTRTOINT %4\n"
Expand All @@ -259,7 +259,7 @@ TEST_F(GISelMITest, TestKnownBitsPtrToIntViceVersa) {
EXPECT_EQ(256u, Res.One.getZExtValue());
EXPECT_EQ(0xfffffeffu, Res.Zero.getZExtValue());
}
TEST_F(GISelMITest, TestKnownBitsXOR) {
TEST_F(AArch64GISelMITest, TestKnownBitsXOR) {
StringRef MIRString = " %3:_(s8) = G_CONSTANT i8 4\n"
" %4:_(s8) = G_CONSTANT i8 7\n"
" %5:_(s8) = G_XOR %3, %4\n"
Expand All @@ -276,7 +276,7 @@ TEST_F(GISelMITest, TestKnownBitsXOR) {
EXPECT_EQ(252u, Res.Zero.getZExtValue());
}

TEST_F(GISelMITest, TestKnownBits) {
TEST_F(AArch64GISelMITest, TestKnownBits) {

StringRef MIR = " %3:_(s32) = G_TRUNC %0\n"
" %4:_(s32) = G_TRUNC %1\n"
Expand Down Expand Up @@ -306,7 +306,7 @@ TEST_F(GISelMITest, TestKnownBits) {
EXPECT_EQ(Known.Zero, Zeroes);
}

TEST_F(GISelMITest, TestSignBitIsZero) {
TEST_F(AArch64GISelMITest, TestSignBitIsZero) {
setUp();
if (!TM)
return;
Expand All @@ -321,7 +321,7 @@ TEST_F(GISelMITest, TestSignBitIsZero) {
EXPECT_FALSE(KnownBits.signBitIsZero(SignBit.getReg(0)));
}

TEST_F(GISelMITest, TestNumSignBitsConstant) {
TEST_F(AArch64GISelMITest, TestNumSignBitsConstant) {
StringRef MIRString = " %3:_(s8) = G_CONSTANT i8 1\n"
" %4:_(s8) = COPY %3\n"

Expand Down Expand Up @@ -353,7 +353,7 @@ TEST_F(GISelMITest, TestNumSignBitsConstant) {
EXPECT_EQ(3u, Info.computeNumSignBits(CopyRegNeg32));
}

TEST_F(GISelMITest, TestNumSignBitsSext) {
TEST_F(AArch64GISelMITest, TestNumSignBitsSext) {
StringRef MIRString = " %3:_(p0) = G_IMPLICIT_DEF\n"
" %4:_(s8) = G_LOAD %3 :: (load 1)\n"
" %5:_(s32) = G_SEXT %4\n"
Expand All @@ -373,7 +373,7 @@ TEST_F(GISelMITest, TestNumSignBitsSext) {
EXPECT_EQ(32u, Info.computeNumSignBits(CopySextNeg1));
}

TEST_F(GISelMITest, TestNumSignBitsTrunc) {
TEST_F(AArch64GISelMITest, TestNumSignBitsTrunc) {
StringRef MIRString = " %3:_(p0) = G_IMPLICIT_DEF\n"
" %4:_(s32) = G_LOAD %3 :: (load 4)\n"
" %5:_(s8) = G_TRUNC %4\n"
Expand All @@ -398,3 +398,36 @@ TEST_F(GISelMITest, TestNumSignBitsTrunc) {
EXPECT_EQ(8u, Info.computeNumSignBits(CopyTruncNeg1));
EXPECT_EQ(5u, Info.computeNumSignBits(CopyTrunc7));
}

TEST_F(AMDGPUGISelMITest, TestNumSignBitsTrunc) {
StringRef MIRString =
" %3:_(<4 x s32>) = G_IMPLICIT_DEF\n"
" %4:_(s32) = G_IMPLICIT_DEF\n"
" %5:_(s32) = G_AMDGPU_BUFFER_LOAD_UBYTE %3, %4, %4, %4, 0, 0, 0 :: (load 1)\n"
" %6:_(s32) = COPY %5\n"

" %7:_(s32) = G_AMDGPU_BUFFER_LOAD_SBYTE %3, %4, %4, %4, 0, 0, 0 :: (load 1)\n"
" %8:_(s32) = COPY %7\n"

" %9:_(s32) = G_AMDGPU_BUFFER_LOAD_USHORT %3, %4, %4, %4, 0, 0, 0 :: (load 2)\n"
" %10:_(s32) = COPY %9\n"

" %11:_(s32) = G_AMDGPU_BUFFER_LOAD_SSHORT %3, %4, %4, %4, 0, 0, 0 :: (load 2)\n"
" %12:_(s32) = COPY %11\n";

setUp(MIRString);
if (!TM)
return;

Register CopyLoadUByte = Copies[Copies.size() - 4];
Register CopyLoadSByte = Copies[Copies.size() - 3];
Register CopyLoadUShort = Copies[Copies.size() - 2];
Register CopyLoadSShort = Copies[Copies.size() - 1];

GISelKnownBits Info(*MF);

EXPECT_EQ(24u, Info.computeNumSignBits(CopyLoadUByte));
EXPECT_EQ(25u, Info.computeNumSignBits(CopyLoadSByte));
EXPECT_EQ(16u, Info.computeNumSignBits(CopyLoadUShort));
EXPECT_EQ(17u, Info.computeNumSignBits(CopyLoadSShort));
}
114 changes: 57 additions & 57 deletions llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions llvm/unittests/CodeGen/GlobalISel/LegalizerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DefineLegalizerInfo(ALegalizer, {
getActionDefinitionsBuilder(G_SHL).legalFor({{s32, s32}});
})

TEST_F(GISelMITest, BasicLegalizerTest) {
TEST_F(AArch64GISelMITest, BasicLegalizerTest) {
StringRef MIRString = R"(
%vptr:_(p0) = COPY $x4
%v:_(<2 x s8>) = G_LOAD %vptr:_(p0) :: (load 2, align 1)
Expand Down Expand Up @@ -85,7 +85,7 @@ TEST_F(GISelMITest, BasicLegalizerTest) {
// Making sure the legalization finishes successfully w/o failure to combine
// away all the legalization artifacts regardless of the order of their
// creation.
TEST_F(GISelMITest, UnorderedArtifactCombiningTest) {
TEST_F(AArch64GISelMITest, UnorderedArtifactCombiningTest) {
StringRef MIRString = R"(
%vptr:_(p0) = COPY $x4
%v:_(<2 x s8>) = G_LOAD %vptr:_(p0) :: (load 2, align 1)
Expand Down Expand Up @@ -169,7 +169,7 @@ TEST_F(GISelMITest, UnorderedArtifactCombiningTest) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckString)) << *MF;
}

TEST_F(GISelMITest, UnorderedArtifactCombiningManyCopiesTest) {
TEST_F(AArch64GISelMITest, UnorderedArtifactCombiningManyCopiesTest) {
StringRef MIRString = R"(
%vptr:_(p0) = COPY $x4
%v:_(<2 x s8>) = G_LOAD %vptr:_(p0) :: (load 2, align 1)
Expand Down
27 changes: 13 additions & 14 deletions llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "GISelMITest.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"

TEST_F(GISelMITest, TestBuildConstantFConstant) {
TEST_F(AArch64GISelMITest, TestBuildConstantFConstant) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -37,11 +37,10 @@ TEST_F(GISelMITest, TestBuildConstantFConstant) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}


#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG

TEST_F(GISelMITest, TestBuildConstantFConstantDeath) {
TEST_F(AArch64GISelMITest, TestBuildConstantFConstantDeath) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -73,7 +72,7 @@ TEST_F(GISelMITest, TestBuildConstantFConstantDeath) {
#endif
#endif

TEST_F(GISelMITest, DstOpSrcOp) {
TEST_F(AArch64GISelMITest, DstOpSrcOp) {
setUp();
if (!TM)
return;
Expand All @@ -99,7 +98,7 @@ TEST_F(GISelMITest, DstOpSrcOp) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildUnmerge) {
TEST_F(AArch64GISelMITest, BuildUnmerge) {
setUp();
if (!TM)
return;
Expand All @@ -120,7 +119,7 @@ TEST_F(GISelMITest, BuildUnmerge) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, TestBuildFPInsts) {
TEST_F(AArch64GISelMITest, TestBuildFPInsts) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -156,7 +155,7 @@ TEST_F(GISelMITest, TestBuildFPInsts) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildIntrinsic) {
TEST_F(AArch64GISelMITest, BuildIntrinsic) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -185,7 +184,7 @@ TEST_F(GISelMITest, BuildIntrinsic) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildXor) {
TEST_F(AArch64GISelMITest, BuildXor) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -214,7 +213,7 @@ TEST_F(GISelMITest, BuildXor) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildBitCounts) {
TEST_F(AArch64GISelMITest, BuildBitCounts) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -242,7 +241,7 @@ TEST_F(GISelMITest, BuildBitCounts) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildCasts) {
TEST_F(AArch64GISelMITest, BuildCasts) {
setUp();
if (!TM)
return;
Expand All @@ -267,7 +266,7 @@ TEST_F(GISelMITest, BuildCasts) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildMinMax) {
TEST_F(AArch64GISelMITest, BuildMinMax) {
setUp();
if (!TM)
return;
Expand All @@ -293,7 +292,7 @@ TEST_F(GISelMITest, BuildMinMax) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildAtomicRMW) {
TEST_F(AArch64GISelMITest, BuildAtomicRMW) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -324,7 +323,7 @@ TEST_F(GISelMITest, BuildAtomicRMW) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildMerge) {
TEST_F(AArch64GISelMITest, BuildMerge) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -363,7 +362,7 @@ TEST_F(GISelMITest, BuildMerge) {
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
}

TEST_F(GISelMITest, BuildAddoSubo) {
TEST_F(AArch64GISelMITest, BuildAddoSubo) {
setUp();
if (!TM)
return;
Expand Down
18 changes: 9 additions & 9 deletions llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace MIPatternMatch;

namespace {

TEST_F(GISelMITest, MatchIntConstant) {
TEST_F(AArch64GISelMITest, MatchIntConstant) {
setUp();
if (!TM)
return;
Expand All @@ -41,7 +41,7 @@ TEST_F(GISelMITest, MatchIntConstant) {
EXPECT_EQ(Cst, 42);
}

TEST_F(GISelMITest, MatchBinaryOp) {
TEST_F(AArch64GISelMITest, MatchBinaryOp) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -139,7 +139,7 @@ TEST_F(GISelMITest, MatchBinaryOp) {
EXPECT_EQ(Src1, TruncCopy1.getReg(0));
}

TEST_F(GISelMITest, MatchICmp) {
TEST_F(AArch64GISelMITest, MatchICmp) {
setUp();
if (!TM)
return;
Expand All @@ -164,7 +164,7 @@ TEST_F(GISelMITest, MatchICmp) {
EXPECT_EQ(Copies[1], Reg1);
}

TEST_F(GISelMITest, MatchFCmp) {
TEST_F(AArch64GISelMITest, MatchFCmp) {
setUp();
if (!TM)
return;
Expand All @@ -189,7 +189,7 @@ TEST_F(GISelMITest, MatchFCmp) {
EXPECT_EQ(Copies[1], Reg1);
}

TEST_F(GISelMITest, MatchFPUnaryOp) {
TEST_F(AArch64GISelMITest, MatchFPUnaryOp) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -251,7 +251,7 @@ TEST_F(GISelMITest, MatchFPUnaryOp) {
EXPECT_NE(TmpFP16, TmpFP);
}

TEST_F(GISelMITest, MatchExtendsTrunc) {
TEST_F(AArch64GISelMITest, MatchExtendsTrunc) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -298,7 +298,7 @@ TEST_F(GISelMITest, MatchExtendsTrunc) {
EXPECT_EQ(Src0, Copies[0]);
}

TEST_F(GISelMITest, MatchSpecificType) {
TEST_F(AArch64GISelMITest, MatchSpecificType) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -335,7 +335,7 @@ TEST_F(GISelMITest, MatchSpecificType) {
EXPECT_EQ(Src0, Copies[0]);
}

TEST_F(GISelMITest, MatchCombinators) {
TEST_F(AArch64GISelMITest, MatchCombinators) {
setUp();
if (!TM)
return;
Expand Down Expand Up @@ -369,7 +369,7 @@ TEST_F(GISelMITest, MatchCombinators) {
EXPECT_FALSE(match);
}

TEST_F(GISelMITest, MatchMiscellaneous) {
TEST_F(AArch64GISelMITest, MatchMiscellaneous) {
setUp();
if (!TM)
return;
Expand Down