diff options
Diffstat (limited to 'llvm/unittests/IR/InstructionsTest.cpp')
-rw-r--r-- | llvm/unittests/IR/InstructionsTest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index ea2265655cb..556c41058e7 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -1046,6 +1046,60 @@ TEST(InstructionsTest, PhiMightNotBeFPMathOperator) { FP->deleteValue(); } +TEST(InstructionsTest, FPCallIsFPMathOperator) { + LLVMContext C; + + Type *ITy = Type::getInt32Ty(C); + FunctionType *IFnTy = FunctionType::get(ITy, {}); + Value *ICallee = Constant::getNullValue(IFnTy->getPointerTo()); + std::unique_ptr<CallInst> ICall(CallInst::Create(IFnTy, ICallee, {}, "")); + EXPECT_FALSE(isa<FPMathOperator>(ICall)); + + Type *VITy = VectorType::get(ITy, 2); + FunctionType *VIFnTy = FunctionType::get(VITy, {}); + Value *VICallee = Constant::getNullValue(VIFnTy->getPointerTo()); + std::unique_ptr<CallInst> VICall(CallInst::Create(VIFnTy, VICallee, {}, "")); + EXPECT_FALSE(isa<FPMathOperator>(VICall)); + + Type *AITy = ArrayType::get(ITy, 2); + FunctionType *AIFnTy = FunctionType::get(AITy, {}); + Value *AICallee = Constant::getNullValue(AIFnTy->getPointerTo()); + std::unique_ptr<CallInst> AICall(CallInst::Create(AIFnTy, AICallee, {}, "")); + EXPECT_FALSE(isa<FPMathOperator>(AICall)); + + Type *FTy = Type::getFloatTy(C); + FunctionType *FFnTy = FunctionType::get(FTy, {}); + Value *FCallee = Constant::getNullValue(FFnTy->getPointerTo()); + std::unique_ptr<CallInst> FCall(CallInst::Create(FFnTy, FCallee, {}, "")); + EXPECT_TRUE(isa<FPMathOperator>(FCall)); + + Type *VFTy = VectorType::get(FTy, 2); + FunctionType *VFFnTy = FunctionType::get(VFTy, {}); + Value *VFCallee = Constant::getNullValue(VFFnTy->getPointerTo()); + std::unique_ptr<CallInst> VFCall(CallInst::Create(VFFnTy, VFCallee, {}, "")); + EXPECT_TRUE(isa<FPMathOperator>(VFCall)); + + Type *AFTy = ArrayType::get(FTy, 2); + FunctionType *AFFnTy = FunctionType::get(AFTy, {}); + Value *AFCallee = Constant::getNullValue(AFFnTy->getPointerTo()); + std::unique_ptr<CallInst> AFCall(CallInst::Create(AFFnTy, AFCallee, {}, "")); + EXPECT_TRUE(isa<FPMathOperator>(AFCall)); + + Type *AVFTy = ArrayType::get(VFTy, 2); + FunctionType *AVFFnTy = FunctionType::get(AVFTy, {}); + Value *AVFCallee = Constant::getNullValue(AVFFnTy->getPointerTo()); + std::unique_ptr<CallInst> AVFCall( + CallInst::Create(AVFFnTy, AVFCallee, {}, "")); + EXPECT_TRUE(isa<FPMathOperator>(AVFCall)); + + Type *AAVFTy = ArrayType::get(AVFTy, 2); + FunctionType *AAVFFnTy = FunctionType::get(AAVFTy, {}); + Value *AAVFCallee = Constant::getNullValue(AAVFFnTy->getPointerTo()); + std::unique_ptr<CallInst> AAVFCall( + CallInst::Create(AAVFFnTy, AAVFCallee, {}, "")); + EXPECT_TRUE(isa<FPMathOperator>(AAVFCall)); +} + TEST(InstructionsTest, FNegInstruction) { LLVMContext Context; Type *FltTy = Type::getFloatTy(Context); |