//===- IVDescriptorsTest.cpp - IVDescriptors unit tests -------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/Analysis/IVDescriptors.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/AsmParser/Parser.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Module.h" #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" usingnamespacellvm; /// Build the loop info and scalar evolution for the function and run the Test. static void runWithLoopInfoAndSE( Module &M, StringRef FuncName, function_ref<void(Function &F, LoopInfo &LI, ScalarEvolution &SE)> Test) { … } static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { … } // This tests that IVDescriptors can obtain the induction binary operator for // integer induction variables. And getExactFPMathInst() correctly return the // expected behavior, i.e. no FMF algebra. TEST(IVDescriptorsTest, LoopWithSingleLatch) { … } // Depending on how SCEV deals with ptrtoint cast, the step of a phi could be // a pointer, and InductionDescriptor used to fail with an assertion. // So just check that it doesn't assert. TEST(IVDescriptorsTest, LoopWithPtrToInt) { … } // This tests that correct identity value is returned for a RecurrenceDescriptor // that describes FMin reduction idiom. TEST(IVDescriptorsTest, FMinRednIdentity) { … } // This tests that correct identity value is returned for a RecurrenceDescriptor // that describes FMax reduction idiom. TEST(IVDescriptorsTest, FMaxRednIdentity) { … }