Repository: ggerganov/llama.cpp
File: ggml/src/ggml-cpu/llamafile/sgemm.cpp (C++)

Code before:
            do {
                aoffsets[0] = aoffset;
                for (int it = 1; it< 8; it++)
                    aoffsets[it] = aoffsets[it-1] + lda;
                aoffset += 8 * lda;
                i = (cols >> 3);
                if (i > 0) {
                    do {
                        for (int it = 0; it< 8; it++) {
                            arr[it] = __builtin_vsx_lxvp(0, (__vector_pair*)aoffsets[it]);
                            __builtin_vsx_disassemble_pair(c[it], &arr[it]);
                            c1[it] = c[it][0];
                            c2[it] = c[it][1];
                        }

                        vector_permute_store_8(c1, boffset);
                        vector_permute_store_8(c2, boffset+32);
                        for (int it = 0; it < 4; it++)
                            aoffsets[it] = aoffsets[it] + 8*lda;
                        boffset += 64;
                        i--;
                    } while(i > 0);
                }
                if (cols & 4) {
                    for (int it = 0; it < 8 ; it++)
                        c1[it] = vec_xl(0, aoffsets[it]);
                    vector_permute_store_8(c1, boffset);
                }
            j--;
            } while(j > 0);
        }

        if (rows & 4) {
            aoffsets[0] = aoffset;
            for (int it = 1; it < 4; it++)
                aoffsets[it] = aoffsets[it-1] + lda;
            aoffset += 4 * lda;
            i = (cols >> 3);
            if (i > 0) {
                do {
                    for (int it = 0; it < 4; it++) {
                        arr[it] = __builtin_vsx_lxvp(0, (__vector_pair*)aoffsets[it]);
                        __builtin_vsx_disassemble_pair(c[it], &arr[it]);
                        c1[it] = c[it][0];
                        c2[it] = c[it][1];
                    }
                    vector_permute_store_4(c1, boffset);
                    vector_permute_store_4(c2, boffset+16);
                    for (int it = 0; it < 4; it++)
                        aoffsets[it] += 8*lda;
                    boffset += 32;

Review comment (suggestion):
```suggestion
                for (int it = 1; it < 8; it++)
```

Code after:
        t5 = vec_xxpermdi(t1, t2, 0);
        t6 = vec_xxpermdi(t3, t4, 0);
        t7 = vec_xxpermdi(t1, t2, 3);
        t8 = vec_xxpermdi(t3, t4, 3);

        vec_xst(t5, 0, vecOffset + 16);
        vec_xst(t6, 0, vecOffset + 20);
        vec_xst(t7, 0, vecOffset + 24);
        vec_xst(t8, 0, vecOffset + 28);
    }

    void packTranspose(const float * a, int64_t lda, int rows, int cols, float * vec) {
        int64_t i, j;
        float * aoffsets[8];
        float * aoffset = NULL, * boffset = NULL;
        __vector_pair arr[8];
        vector float c[8][2] = {0};
        vector float c1[8] = {0};
        vector float c2[8] = {0};
        aoffset = const_cast<float *>(a);
        boffset = vec;
        j = (rows >> 3);
        if (j > 0) {
            do {
                aoffsets[0] = aoffset;
                for (int it = 1; it < 8; it++)
                    aoffsets[it] = aoffsets[it-1] + lda;
                aoffset += 8 * lda;
                i = (cols >> 3);
                if (i > 0) {
                    do {
                        for (int it = 0; it < 8; it++) {
                            arr[it] = __builtin_vsx_lxvp(0, (__vector_pair*)aoffsets[it]);
                            __builtin_vsx_disassemble_pair(c[it], &arr[it]);
                            c1[it] = c[it][0];
                            c2[it] = c[it][1];
                        }

                        vector_permute_store_8(c1, boffset);
                        vector_permute_store_8(c2, boffset + 32);
                        boffset += 64;
                        i--;
                        if (i > 0) {
                           for (int it = 0; it < 8; it++) {
                               aoffsets[it] = aoffsets[it] + 8;
                           }
                        }
                    } while(i > 0);
                }
                if (cols & 4) {
                    for (int it = 0; it < 8 ; it++)