https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112579
Bug ID: 112579 Summary: bb vectorizer failed to reduction sum += inv >> {1,2,3,4,5,6,7,8} Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: liuhongt at gcc dot gnu.org Blocks: 112325 Target Milestone: --- This is from PR112325 unsigned foo (unsigned * restrict s, unsigned qh, unsigned * restrict qs) { unsigned int sumi = 0; sumi += (qh >> 0); sumi += (qh >> 1); sumi += (qh >> 2); sumi += (qh >> 3); sumi += (qh >> 4); sumi += (qh >> 5); sumi += (qh >> 6); sumi += (qh >> 7); sumi += (qh >> 8); sumi += (qh >> 9); sumi += (qh >> 10); sumi += (qh >> 11); sumi += (qh >> 12); sumi += (qh >> 13); sumi += (qh >> 14); sumi += (qh >> 15); return sumi; } test2.c:28:8: note: nunits = 8 test2.c:28:8: missed: Build SLP failed: unrolling required in basic block SLP test2.c:28:8: note: Build SLP for _5 = qh_16(D) >> 5; test2.c:28:8: note: get vectype for scalar type (group size 14): unsigned int test2.c:28:8: note: vectype: vector(8) unsigned int test2.c:28:8: note: nunits = 8 test2.c:28:8: missed: Build SLP failed: unrolling required in basic block SLP test2.c:28:8: note: Build SLP for _4 = qh_16(D) >> 4; test2.c:28:8: note: get vectype for scalar type (group size 14): unsigned int test2.c:28:8: note: vectype: vector(8) unsigned int test2.c:28:8: note: nunits = 8 test2.c:28:8: missed: Build SLP failed: unrolling required in basic block SLP test2.c:28:8: note: Build SLP for _3 = qh_16(D) >> 3; test2.c:28:8: note: get vectype for scalar type (group size 14): unsigned int test2.c:28:8: note: vectype: vector(8) unsigned int test2.c:28:8: note: nunits = 8 test2.c:28:8: missed: Build SLP failed: unrolling required in basic block SLP test2.c:28:8: note: Build SLP for _1 = qh_16(D) >> 1; test2.c:28:8: note: get vectype for scalar type (group size 14): unsigned int test2.c:28:8: note: vectype: vector(8) unsigned int test2.c:28:8: note: nunits = 8 test2.c:28:8: missed: Build SLP failed: unrolling required in basic block SLP test2.c:28:8: note: SLP discovery for node 0x6415a60 failed test2.c:28:8: note: SLP discovery failed rewrite it as unsigned foo1 (unsigned * restrict s, unsigned qh, unsigned * restrict qs) { unsigned int sumi = 0; for (int i = 0; i != 16; i++) sumi += qh >> i; return sumi; } loop vectorizer successfully vectorize it. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112325 [Bug 112325] Missed vectorization of reduction after unrolling