https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114435
Bug ID: 114435 Summary: Bad code generated when SSA and PCOM are enabled. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jchrist at linux dot ibm.com Target Milestone: --- Created attachment 57783 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57783&action=edit Reproducer While investigating a preformance difference between clang and gcc on imagemagick I discovered that attached test case gets badly vectorized due to pcom pass. If I disable pcom and set the vector cost model to unlimited, SLP produces exactly what I would expect. With pcom, however, the code becomes considerably bigger and, depending on the target, even mixes scalar and vectorized operations while the whole body of the loop should be vectorizable via SLP. Difference is observed between the output of ``` gcc -O3 -fvect-cost-model=unlimited fma.c -c ``` and ``` gcc -O3 -fvect-cost-model=unlimited fma.c -c -fdisable-tree-pcom ``` I am wondering if the pcom pass should be after SLP vectorization?