https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106770
--- Comment #8 from Surya Kumari Jangala <jskumari at gcc dot gnu.org> --- While the first two xxpermdi's are fine, the 3rd one is a bug. It is incorrect. Here is the C code inlined into assembly: _Z4cmp2dd: .LFB1: .cfi_startproc // vector double va = vec_promote(a, 1); xxpermdi 1,1,1,0 // vector double vb = vec_promote(b, 1); xxpermdi 2,2,2,0 // vector long long vlt = (vector long long)vec_cmplt(va, vb); xvcmpgtdp 33,2,1 // vector long long vgt = (vector long long)vec_cmplt(vb, va); xvcmpgtdp 32,1,2 // vector signed long long vr = vec_sub(vlt, vgt); vsubudm 0,1,0 // return vec_extract(vr, 1); xxpermdi 0,32,32,3 mfvsrd 3,0 extsw 3,3 blr The code generated for vec_extract(vr, 1) is incorrect. We want to extract the 1st element but 'xxpermdi 0,32,32,3' copies the 0th element of vsx32 into the 0th and 1st elements of vsx0. The mfvsrd instruction does extract the 1st element, but this is not the first element of the result of the vec_sub.