mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Use a shorter name for the IRBuilder member. This will help the tests
I'm adding next be a lot more readable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198534 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d02c84191
commit
3f62424ea0
@ -35,168 +35,168 @@ struct PatternMatchTest : ::testing::Test {
|
||||
OwningPtr<Module> M;
|
||||
Function *F;
|
||||
BasicBlock *BB;
|
||||
IRBuilder<true, NoFolder> Builder;
|
||||
IRBuilder<true, NoFolder> IRB;
|
||||
|
||||
PatternMatchTest()
|
||||
: M(new Module("PatternMatchTestModule", Ctx)),
|
||||
F(Function::Create(
|
||||
FunctionType::get(Type::getVoidTy(Ctx), /* IsVarArg */ false),
|
||||
Function::ExternalLinkage, "f", M.get())),
|
||||
BB(BasicBlock::Create(Ctx, "entry", F)), Builder(BB) {}
|
||||
BB(BasicBlock::Create(Ctx, "entry", F)), IRB(BB) {}
|
||||
};
|
||||
|
||||
TEST_F(PatternMatchTest, FloatingPointOrderedMin) {
|
||||
Type *FltTy = Builder.getFloatTy();
|
||||
Type *FltTy = IRB.getFloatTy();
|
||||
Value *L = ConstantFP::get(FltTy, 1.0);
|
||||
Value *R = ConstantFP::get(FltTy, 2.0);
|
||||
Value *MatchL, *MatchR;
|
||||
|
||||
// Test OLT.
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLT(L, R), L, R)));
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLT(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test OLE.
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLE(L, R), L, R)));
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLE(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test no match on OGE.
|
||||
EXPECT_FALSE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGE(L, R), L, R)));
|
||||
EXPECT_FALSE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGE(L, R), L, R)));
|
||||
|
||||
// Test no match on OGT.
|
||||
EXPECT_FALSE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGT(L, R), L, R)));
|
||||
EXPECT_FALSE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGT(L, R), L, R)));
|
||||
|
||||
// Test match on OGE with inverted select.
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGE(L, R), R, L)));
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGE(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test match on OGT with inverted select.
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGT(L, R), R, L)));
|
||||
EXPECT_TRUE(m_OrdFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGT(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
}
|
||||
|
||||
TEST_F(PatternMatchTest, FloatingPointOrderedMax) {
|
||||
Type *FltTy = Builder.getFloatTy();
|
||||
Type *FltTy = IRB.getFloatTy();
|
||||
Value *L = ConstantFP::get(FltTy, 1.0);
|
||||
Value *R = ConstantFP::get(FltTy, 2.0);
|
||||
Value *MatchL, *MatchR;
|
||||
|
||||
// Test OGT.
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGT(L, R), L, R)));
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGT(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test OGE.
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOGE(L, R), L, R)));
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOGE(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test no match on OLE.
|
||||
EXPECT_FALSE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLE(L, R), L, R)));
|
||||
EXPECT_FALSE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLE(L, R), L, R)));
|
||||
|
||||
// Test no match on OLT.
|
||||
EXPECT_FALSE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLT(L, R), L, R)));
|
||||
EXPECT_FALSE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLT(L, R), L, R)));
|
||||
|
||||
// Test match on OLE with inverted select.
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLE(L, R), R, L)));
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLE(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test match on OLT with inverted select.
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpOLT(L, R), R, L)));
|
||||
EXPECT_TRUE(m_OrdFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpOLT(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
}
|
||||
|
||||
TEST_F(PatternMatchTest, FloatingPointUnorderedMin) {
|
||||
Type *FltTy = Builder.getFloatTy();
|
||||
Type *FltTy = IRB.getFloatTy();
|
||||
Value *L = ConstantFP::get(FltTy, 1.0);
|
||||
Value *R = ConstantFP::get(FltTy, 2.0);
|
||||
Value *MatchL, *MatchR;
|
||||
|
||||
// Test ULT.
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULT(L, R), L, R)));
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULT(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test ULE.
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULE(L, R), L, R)));
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULE(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test no match on UGE.
|
||||
EXPECT_FALSE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGE(L, R), L, R)));
|
||||
EXPECT_FALSE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGE(L, R), L, R)));
|
||||
|
||||
// Test no match on UGT.
|
||||
EXPECT_FALSE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGT(L, R), L, R)));
|
||||
EXPECT_FALSE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGT(L, R), L, R)));
|
||||
|
||||
// Test match on UGE with inverted select.
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGE(L, R), R, L)));
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGE(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test match on UGT with inverted select.
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGT(L, R), R, L)));
|
||||
EXPECT_TRUE(m_UnordFMin(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGT(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
}
|
||||
|
||||
TEST_F(PatternMatchTest, FloatingPointUnorderedMax) {
|
||||
Type *FltTy = Builder.getFloatTy();
|
||||
Type *FltTy = IRB.getFloatTy();
|
||||
Value *L = ConstantFP::get(FltTy, 1.0);
|
||||
Value *R = ConstantFP::get(FltTy, 2.0);
|
||||
Value *MatchL, *MatchR;
|
||||
|
||||
// Test UGT.
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGT(L, R), L, R)));
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGT(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test UGE.
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpUGE(L, R), L, R)));
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpUGE(L, R), L, R)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test no match on ULE.
|
||||
EXPECT_FALSE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULE(L, R), L, R)));
|
||||
EXPECT_FALSE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULE(L, R), L, R)));
|
||||
|
||||
// Test no match on ULT.
|
||||
EXPECT_FALSE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULT(L, R), L, R)));
|
||||
EXPECT_FALSE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULT(L, R), L, R)));
|
||||
|
||||
// Test match on ULE with inverted select.
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULE(L, R), R, L)));
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULE(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
|
||||
// Test match on ULT with inverted select.
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR)).match(
|
||||
Builder.CreateSelect(Builder.CreateFCmpULT(L, R), R, L)));
|
||||
EXPECT_TRUE(m_UnordFMax(m_Value(MatchL), m_Value(MatchR))
|
||||
.match(IRB.CreateSelect(IRB.CreateFCmpULT(L, R), R, L)));
|
||||
EXPECT_EQ(L, MatchL);
|
||||
EXPECT_EQ(R, MatchR);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user