https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116004
Bug ID: 116004 Summary: PPC64 vector Intrinsic vec_first_mismatch_or_eos_index generates poor code Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: munroesj at gcc dot gnu.org Target Milestone: --- GCC13 generates the following code for the intrinsic vec_first_mismatch_or_eos_index -mcpu=power9 -O3: 00000000000000c0 <test_intrn_first_mismatch_or_eos_index_PWR9>: c0: d1 02 00 f0 xxspltib vs32,0 c4: 07 00 22 10 vcmpneb v1,v2,v0 c8: 07 00 03 10 vcmpneb v0,v3,v0 cc: 07 19 42 10 vcmpnezb v2,v2,v3 d0: 17 04 21 f0 xxland vs33,vs33,vs32 d4: 57 0d 42 f0 xxlorc vs34,vs34,vs33 d8: 02 16 61 10 vctzlsbb r3,v2 dc: b4 07 63 7c extsw r3,r3 e0: 20 00 80 4e blr The use of vcmpneb to compare for EOS is redundant to the vcmpnezb instruction (which includes the EOS compares). The additional xxland/xxorc logic is only necessary because of the extra vcmpneb compares. All you need is a single vcmpnezb as it already handles the a/b mismatch and EOS tests for both operands. For example: 0000000000000070 <test_vec_first_mismatch_byte_or_eos_index>: 70: 07 19 42 10 vcmpnezb v2,v2,v3 74: 02 16 61 10 vctzlsbb r3,v2 78: b4 07 63 7c extsw r3,r3 7c: 20 00 80 4e blr