https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102056
Bug ID: 102056 Summary: VEC_PERM_EXPR of different sizes are not combined Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- take this on x86_64 with -mavx2: #define vector __attribute__((vector_size(16))) vector char g(vector char a) { return __builtin_shuffle(a,(vector char){15,14,13,12,11,10,9,8,7,6,5,4,3,2,1, 0}); } vector char g1(vector char a) { vector char t= __builtin_shuffle(a,(vector char){7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,}); vector long long t1 = (vector long long)t; t1 = __builtin_shuffle(t1, (vector long long){1,0}); return (vector char)t1; } --- CUT --- We get: g: .cfi_startproc vpshufb .LC0(%rip), %xmm0, %xmm0 ret g1: vpshufb .LC1(%rip), %xmm0, %xmm0 vpalignr $8, %xmm0, %xmm0, %xmm0 ret But really these two functions are the same.