[llvm] r254386 - [X86] Use array_lengthof instead of calculating manually. Also change index types to size_t to match.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 30 22:27:52 PST 2015
On Mon, Nov 30, 2015 at 10:13 PM, Craig Topper via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: ctopper
> Date: Tue Dec 1 00:13:13 2015
> New Revision: 254386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254386&view=rev
> Log:
> [X86] Use array_lengthof instead of calculating manually. Also change
> index types to size_t to match.
>
> Modified:
> llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
>
> Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=254386&r1=254385&r2=254386&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Dec 1 00:13:13 2015
> @@ -3517,23 +3517,23 @@ unsigned X86InstrInfo::getFMA3OpcodeToCo
> bool IsIntrinOpcode;
> isFMA3(Opc, &IsIntrinOpcode);
>
> - unsigned GroupsNum;
> + size_t GroupsNum;
> const unsigned (*OpcodeGroups)[3];
>
Worth replacing these two variables ^ with one ArrayRef<unsigned[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;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151130/6639dd2f/attachment.html>
More information about the llvm-commits
mailing list