How is it possible to get gccgo produce vectorized code?

I’m trying to convince gccgo without success to vectorize the following snippet:

package foo

func Sum(v []float32) float32 {
    var sum float32 = 0
    for _, x := range v {
        sum += x
    return sum

I’m verifying the assembly generated by:

$ gccgo -O3 -ffast-math -march=native -S test.go

gccgo version is:

$ gccgo --version
gccgo (Ubuntu 4.9-20140406-0ubuntu1) 4.9.0 20140405 (experimental) [trunk revision 209157]

Isn’t gccgo supposed to be able to vectorize this code? the equivalent C code with the same gcc options is perfectly vectorized with AVX instructions…


here you have the corresponding C example:

#include <stdlib.h>

float sum(float *v, size_t n) {
    size_t i;
    float sum = 0;
    for(i = 0; i < n; i++) {
        sum += v[i];
    return sum;

compile with:

$ gcc -O3 -ffast-math -march=native -S test.c

Why not just build the .so or .a with gcc and call the c function from go?