From 9a293e525c52342f7d286ac999dc84d04c8897e9 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 1 Dec 2015 06:13:13 +0000 Subject: [PATCH] [X86] Use array_lengthof instead of calculating manually. Also change index types to size_t to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254386 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrInfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index aaeef465bf5..04b68cd509f 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -3517,23 +3517,23 @@ unsigned X86InstrInfo::getFMA3OpcodeToCommuteOperands(MachineInstr *MI, bool IsIntrinOpcode; isFMA3(Opc, &IsIntrinOpcode); - unsigned GroupsNum; + size_t GroupsNum; const unsigned (*OpcodeGroups)[3]; if (IsIntrinOpcode) { - GroupsNum = sizeof(IntrinOpcodeGroups) / sizeof(IntrinOpcodeGroups[0]); + GroupsNum = array_lengthof(IntrinOpcodeGroups); OpcodeGroups = IntrinOpcodeGroups; } else { - GroupsNum = sizeof(RegularOpcodeGroups) / sizeof(RegularOpcodeGroups[0]); + GroupsNum = array_lengthof(RegularOpcodeGroups); OpcodeGroups = RegularOpcodeGroups; } const unsigned *FoundOpcodesGroup = nullptr; - unsigned FormIndex; + size_t FormIndex; // Look for the input opcode in the corresponding opcodes table. - unsigned GroupIndex = 0; - for (; GroupIndex < GroupsNum && !FoundOpcodesGroup; GroupIndex++) { - for (FormIndex = 0; FormIndex < FormsNum; FormIndex++) { + for (size_t GroupIndex = 0; GroupIndex < GroupsNum && !FoundOpcodesGroup; + ++GroupIndex) { + for (FormIndex = 0; FormIndex < FormsNum; ++FormIndex) { if (OpcodeGroups[GroupIndex][FormIndex] == Opc) { FoundOpcodesGroup = OpcodeGroups[GroupIndex]; break; -- 2.34.1