https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90323
luoxhu at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |luoxhu at gcc dot gnu.org --- Comment #8 from luoxhu at gcc dot gnu.org --- Two minor updates for the case mentioned in #c2: for VEC_SEL (ARG1, ARG2, ARG3): Returns a vector containing the value of either ARG1 or ARG2 depending on the value of ARG3. #include <stdio.h> #include <altivec.h> volatile vector unsigned orig = {0xebebebeb, 0x34343434, 0x76767676, 0x12121212}; volatile vector unsigned mask = {0xffffffff, 0, 0xffffffff, 0}; volatile vector unsigned fill = {0xfefefefe, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc}; volatile vector unsigned expected = {0xfefefefe, 0x34343434, 0xbbbbbbbb, 0x12121212}; __attribute__ ((noinline)) vector unsigned without_sel(vector unsigned l, vector unsigned r, vector unsigned mask) { - l = l & ~r; + l = l & ~mask; l |= mask & r; return l; } __attribute__ ((noinline)) vector unsigned with_sel(vector unsigned l, vector unsigned r, vector unsigned mask) { - return vec_sel(l, mask, r); + return vec_sel(l, r, mask); } int main() { vector unsigned res1 = without_sel(orig, fill, mask); vector unsigned res2 = with_sel(orig, fill, mask); if (!vec_all_eq(res1, expected)) printf ("error1\n"); if (!vec_all_eq(res2, expected)) printf ("error2\n"); return 0; } And the ASM would be: without_sel: xxlxor 35,34,35 xxland 35,35,36 xxlxor 34,34,35 blr .long 0 .byte 0,0,0,0,0,0,0,0 with_sel: xxsel 34,34,35,36 blr .long 0 .byte 0,0,0,0,0,0,0,0