1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[VP][NFCI] Address various clang-tidy warnings

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D104288
This commit is contained in:
Fraser Cormack 2021-06-21 09:50:27 +01:00
parent 95f90b846b
commit 18c509d4ea
2 changed files with 16 additions and 15 deletions

View File

@ -266,7 +266,7 @@ bool ConstrainedFPIntrinsic::classof(const IntrinsicInst *I) {
ElementCount VPIntrinsic::getStaticVectorLength() const { ElementCount VPIntrinsic::getStaticVectorLength() const {
auto GetVectorLengthOfType = [](const Type *T) -> ElementCount { auto GetVectorLengthOfType = [](const Type *T) -> ElementCount {
auto VT = cast<VectorType>(T); const auto *VT = cast<VectorType>(T);
auto ElemCount = VT->getElementCount(); auto ElemCount = VT->getElementCount();
return ElemCount; return ElemCount;
}; };
@ -380,7 +380,7 @@ bool VPIntrinsic::canIgnoreVectorLengthParam() const {
// Check whether "W == vscale * EC.getKnownMinValue()" // Check whether "W == vscale * EC.getKnownMinValue()"
if (EC.isScalable()) { if (EC.isScalable()) {
// Undig the DL // Undig the DL
auto ParMod = this->getModule(); const auto *ParMod = this->getModule();
if (!ParMod) if (!ParMod)
return false; return false;
const auto &DL = ParMod->getDataLayout(); const auto &DL = ParMod->getDataLayout();
@ -393,7 +393,7 @@ bool VPIntrinsic::canIgnoreVectorLengthParam() const {
} }
// standard SIMD operation // standard SIMD operation
auto VLConst = dyn_cast<ConstantInt>(VLParam); const auto *VLConst = dyn_cast<ConstantInt>(VLParam);
if (!VLConst) if (!VLConst)
return false; return false;

View File

@ -32,7 +32,7 @@ protected:
LLVMContext C; LLVMContext C;
SMDiagnostic Err; SMDiagnostic Err;
std::unique_ptr<Module> CreateVPDeclarationModule() { std::unique_ptr<Module> createVPDeclarationModule() {
const char *BinaryIntOpcodes[] = {"add", "sub", "mul", "sdiv", "srem", const char *BinaryIntOpcodes[] = {"add", "sub", "mul", "sdiv", "srem",
"udiv", "urem", "and", "xor", "or", "udiv", "urem", "and", "xor", "or",
"ashr", "lshr", "shl"}; "ashr", "lshr", "shl"};
@ -78,7 +78,7 @@ TEST_F(VPIntrinsicTest, VPIntrinsicsDefScopes) {
/// Check that every VP intrinsic in the test module is recognized as a VP /// Check that every VP intrinsic in the test module is recognized as a VP
/// intrinsic. /// intrinsic.
TEST_F(VPIntrinsicTest, VPModuleComplete) { TEST_F(VPIntrinsicTest, VPModuleComplete) {
std::unique_ptr<Module> M = CreateVPDeclarationModule(); std::unique_ptr<Module> M = createVPDeclarationModule();
assert(M); assert(M);
// Check that all @llvm.vp.* functions in the module are recognized vp // Check that all @llvm.vp.* functions in the module are recognized vp
@ -135,25 +135,24 @@ TEST_F(VPIntrinsicTest, CanIgnoreVectorLength) {
auto *F = M->getFunction("test_static_vlen"); auto *F = M->getFunction("test_static_vlen");
assert(F); assert(F);
const int NumExpected = 12;
const bool Expected[] = {false, true, false, false, false, true, const bool Expected[] = {false, true, false, false, false, true,
false, false, true, false, true, false}; false, false, true, false, true, false};
int i = 0; const auto *ExpectedIt = std::begin(Expected);
for (auto &I : F->getEntryBlock()) { for (auto &I : F->getEntryBlock()) {
VPIntrinsic *VPI = dyn_cast<VPIntrinsic>(&I); VPIntrinsic *VPI = dyn_cast<VPIntrinsic>(&I);
if (!VPI) if (!VPI)
continue; continue;
ASSERT_LT(i, NumExpected); ASSERT_NE(ExpectedIt, std::end(Expected));
ASSERT_EQ(Expected[i], VPI->canIgnoreVectorLengthParam()); ASSERT_EQ(*ExpectedIt, VPI->canIgnoreVectorLengthParam());
++i; ++ExpectedIt;
} }
} }
/// Check that the argument returned by /// Check that the argument returned by
/// VPIntrinsic::get<X>ParamPos(Intrinsic::ID) has the expected type. /// VPIntrinsic::get<X>ParamPos(Intrinsic::ID) has the expected type.
TEST_F(VPIntrinsicTest, GetParamPos) { TEST_F(VPIntrinsicTest, GetParamPos) {
std::unique_ptr<Module> M = CreateVPDeclarationModule(); std::unique_ptr<Module> M = createVPDeclarationModule();
assert(M); assert(M);
for (Function &F : *M) { for (Function &F : *M) {
@ -209,7 +208,7 @@ TEST_F(VPIntrinsicTest, OpcodeRoundTrip) {
/// Check that going from VP intrinsic to Opcode and back results in the same /// Check that going from VP intrinsic to Opcode and back results in the same
/// intrinsic id. /// intrinsic id.
TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) { TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) {
std::unique_ptr<Module> M = CreateVPDeclarationModule(); std::unique_ptr<Module> M = createVPDeclarationModule();
assert(M); assert(M);
unsigned FullTripCounts = 0; unsigned FullTripCounts = 0;
@ -231,7 +230,7 @@ TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) {
/// Check that VPIntrinsic::getDeclarationForParams works. /// Check that VPIntrinsic::getDeclarationForParams works.
TEST_F(VPIntrinsicTest, VPIntrinsicDeclarationForParams) { TEST_F(VPIntrinsicTest, VPIntrinsicDeclarationForParams) {
std::unique_ptr<Module> M = CreateVPDeclarationModule(); std::unique_ptr<Module> M = createVPDeclarationModule();
assert(M); assert(M);
auto OutM = std::make_unique<Module>("", M->getContext()); auto OutM = std::make_unique<Module>("", M->getContext());
@ -251,8 +250,10 @@ TEST_F(VPIntrinsicTest, VPIntrinsicDeclarationForParams) {
// Check that 'old decl' == 'new decl'. // Check that 'old decl' == 'new decl'.
ASSERT_EQ(F.getIntrinsicID(), NewDecl->getIntrinsicID()); ASSERT_EQ(F.getIntrinsicID(), NewDecl->getIntrinsicID());
auto ItNewParams = NewDecl->getFunctionType()->param_begin(); FunctionType::param_iterator ItNewParams =
auto EndItNewParams = NewDecl->getFunctionType()->param_end(); NewDecl->getFunctionType()->param_begin();
FunctionType::param_iterator EndItNewParams =
NewDecl->getFunctionType()->param_end();
for (auto *ParamTy : FuncTy->params()) { for (auto *ParamTy : FuncTy->params()) {
ASSERT_NE(ItNewParams, EndItNewParams); ASSERT_NE(ItNewParams, EndItNewParams);
ASSERT_EQ(*ItNewParams, ParamTy); ASSERT_EQ(*ItNewParams, ParamTy);