Comment 1 for bug 1166642

Revision history for this message
Matthew Gretton-Dann (matthew-gretton-dann) wrote :

This is expected behaviour.

The prototype for vget_lane_f32(x, i) in arm_neon.h is:

__extension__ static __inline float32_t __attribute__ ((__always_inline__))
vget_lane_f32 (float32x2_t __a, const int __b);

The second parameter (__b) must be a compile time constant. (I admit this is not obvious from the header but there is no way to show this in C).

You must therefore do something like the following:

#include <stdio.h>
#include <stdlib.h>

#include <arm_neon.h>

int main() {
    float32x2_t x = vdup_n_f32(123.0f);
    float a = vget_lane_f32(x, 1);
}

Note in C you can't use a variable of type 'const int' as C does not consider that to be a compile time constant. However C++ does allow you to do: const int i = 1; a = vget_lane_f32(x, i);

Note also that the original testcase wouldn't have worked anyway as you were asking for the third lane of a vector with only two lanes.