This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/28367] New: accessing via union on a vector does not cause vec_extract to be used


Take the following code and compile with -O2 -m64 -maltivec -mabi=altivec:
#define vector __attribute__((vector_size(16)))
float f(vector float t)
{
  union {
    vector float t1;
    float t2[4];
  }t5;
  t5.t1 = t;
  return t5.t2[0];
}

Currently we get:
        addi 12,1,-32
        stvx 2,0,12
        ld 11,0(12)
        srdi 9,11,32
        stw 9,-16(1)
        lfs 1,-16(1)
        blr

Which is bad for at least the Cell as we now hit two store load hazards.  We
can remove one if the compile uses the vec_extract patterns causing us to use
stvewx and lfs.

This does not effect x86 as the union is recorded as BLKmode but x86_64 has the
same issue, maybe even worse as there is no need to go through memory there.
X86_64 produces:
f:
.LFB2:
        movaps  %xmm0, -24(%rsp)
        movss   -24(%rsp), %xmm0
        ret
When really it should produce just a ret.


-- 
           Summary: accessing via union on a vector does not cause
                    vec_extract to be used
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: powerpc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28367


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]