https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99517
Bug ID: 99517 Summary: __builtin_convertvector with casts Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: me+gcc.gnu at lelf dot lu Target Milestone: --- #include<stdint.h> typedef int8_t GV __attribute__((vector_size(32),aligned(1))); typedef int32_t IV __attribute__((vector_size(16),aligned(1))); typedef int64_t JV __attribute__((vector_size(32),aligned(1))); typedef double FV __attribute__((vector_size(32),aligned(1))); GV FI(IV x){return(GV)__builtin_convertvector(x,FV);} GV JI(IV x){return(GV)__builtin_convertvector(x,JV);} x86_64 -Os or -O2 $ gcc-11x -Os -c cv.c -mavx2 FI is ok 0000000000000000 <FI>: 0: c5 fa e6 c8 vcvtdq2pd %xmm0,%xmm1 4: c5 f9 70 c0 ee vpshufd $0xee,%xmm0,%xmm0 9: c5 fa e6 c0 vcvtdq2pd %xmm0,%xmm0 d: c4 e3 75 18 c0 01 vinsertf128 $0x1,%xmm0,%ymm1,%ymm0 13: c3 retq but JI is wrong (body of FI) 0000000000000014 <JI>: 14: c5 fa e6 c8 vcvtdq2pd %xmm0,%xmm1 18: c5 f9 70 c0 ee vpshufd $0xee,%xmm0,%xmm0 1d: c5 fa e6 c0 vcvtdq2pd %xmm0,%xmm0 21: c4 e3 75 18 c0 01 vinsertf128 $0x1,%xmm0,%ymm1,%ymm0 27: c3 retq versions: gcc-10x (GCC) 10.2.1 20210227 gcc-11x (GCC) 11.0.1 20210228 (experimental)