https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106069
--- Comment #20 from Xionghu Luo (luoxhu at gcc dot gnu.org) <yinyuefengyi at gmail dot com> --- Another reference is manually change the generated assembly with modifying the source and index vspltw to verify: luoxhu@gcc135 build $ diff q.bad.s q.good.s -U12 --- q.bad.s 2022-08-03 06:30:08.298451116 +0000 +++ q.good.s 2022-08-03 06:30:52.887250451 +0000 @@ -18,31 +18,31 @@ addi 2,2,.TOC.-.LCF0@l .localentry _Z3fooPhPjDv4_jS1_S1_S1_,.-_Z3fooPhPjDv4_jS1_S1_S1_ mflr %r0 std %r0,16(%r1) std %r30,-16(%r1) std %r31,-8(%r1) stdu %r1,-112(%r1) .cfi_def_cfa_offset 112 .cfi_offset 65, 16 .cfi_offset 30, -16 .cfi_offset 31, -8 mr %r30,%r3 - vspltw %v0,%v2,0 + vspltw %v0,%v5,3 mfvsrwz %r7,%vs32 - vspltw %v0,%v3,0 + vspltw %v0,%v4,3 mfvsrwz %r6,%vs32 - vspltw %v0,%v4,0 + vspltw %v0,%v3,3 mfvsrwz %r5,%vs32 - vspltw %v0,%v5,0 + vspltw %v0,%v2,3 mfvsrwz %r31,%vs32 rldicl %r7,%r7,0,32 rldicl %r6,%r6,0,32 rldicl %r5,%r5,0,32 rldicl %r4,%r31,0,32 addis %r3,%r2,.LC0@toc@ha addi %r3,%r3,.LC0@toc@l bl printf nop stb %r31,0(%r30) addi %r1,%r1,112 .cfi_def_cfa_offset 0 luoxhu@gcc135 build $ gcc q.good.s -o q.good luoxhu@gcc135 build $ ./q.good B0: 41fcef98, 91648e8b,7dca18c6,61707865 Which means both register and index are incorrectly used in LE nested vec_select optimization.