0

コード ブロックは、mozilla firefox の qcms transform_util.c からのものです。

    void build_output_lut(struct curveType *trc,
                uint16_t **output_gamma_lut, size_t *output_gamma_lut_length)
{
        if (trc->type == PARAMETRIC_CURVE_TYPE) {
                float gamma_table[256];
                uint16_t i;
                uint16_t *output = malloc(sizeof(uint16_t)*256);

                if (!output) {
                        *output_gamma_lut = NULL;
                        return;
                }

                compute_curve_gamma_table_type_parametric(gamma_table, trc->parameter, trc->count);
                *output_gamma_lut_length = 256;
                for(i = 0; i < 256; i++) {
                        output[i] = (uint16_t)(gamma_table[i] * 65535);
                }
                *output_gamma_lut = output;
        } else {
                if (trc->count == 0) {
                        *output_gamma_lut = build_linear_table(4096);
                        *output_gamma_lut_length = 4096;
                } else if (trc->count == 1) {
                        float gamma = 1./u8Fixed8Number_to_float(trc->data[0]);
                        *output_gamma_lut = build_pow_table(gamma, 4096);
                        *output_gamma_lut_length = 4096;
                } else {
                        //XXX: the choice of a minimum of 256 here is not backed by any theory, 
                        //     measurement or data, however it is what lcms uses.
                        *output_gamma_lut_length = trc->count;
                        if (*output_gamma_lut_length < 256)
                                *output_gamma_lut_length = 256;

                        *output_gamma_lut = invert_lut(trc->data, trc->count, *output_gamma_lut_length);
                }
        }

}

このループの場合:

            for(i = 0; i < 256; i++) {
                    output[i] = (uint16_t)(gamma_table[i] * 65535);
            }

VC2013 では以下が表示されます。

e:\mozilla\hg\nightly\mozilla-central\gfx\qcms\transform_util.c(490) : info C5002: 故「500」,循環未向量化

MSDN ( http://msdn.microsoft.com/en-us/library/jj658585.aspx ) には次のように表示されます。

// Code 500 is emitted if the loop has non-vectorizable flow.
// This can include "if", "break", "continue", the conditional 
// operator "?", or function calls.
// It also encompasses correct definition and use of the induction
// variable "i", in that the increment "++i" or "i++" must be the last
// statement in the loop.

しかし、上記のループには if/break/continue がありません。ベクトル化できない理由がわかりません。

4

1 に答える 1

0

これは、変数「i」が「if」ステートメントのスコープ内にあるという事実によるものと思われます。したがって、「for ループ」スコープに完全に属するわけではありません。

for(int i = 0; /* etc. */ そのような場合、コンパイラのロジックは次のようになります。したがって、ベクトル化はありません。

于 2014-10-02T08:30:34.747 に答える