https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126028
Bug ID: 126028
Summary: GCC trunk vs Intel oneAPI : Missed SLP vectorization
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: Reshma.Roy at amd dot com
Target Milestone: ---
Created attachment 64888
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64888&action=edit
The preprocessed input file to be used for the command mentioned in the
description
Compiler Versions
oneAPI : Intel oneAPI 2025.3
gcc trunk : gcc (GCC) 17.0.0 20260615 (experimental)
commit 256d683ac8ed30459b81b1498390252057e314a9
Context
-------
We compared a hot loop from SPEC2017 becnhmark 508.namd_r in the file
ComputeNonbondedBase.h:990-1034 between GCC trunk and Oneapi. The body inside
the loop is an SLP candidate where oneapi vectorizes it but gcc trunk fails to
do so.
Reduced Testcase
----------------
typedef double BigReal;
struct Position { BigReal x, y, z; };
struct CompAtom {
Position position;
float charge;
short vdwType;
unsigned char partition;
unsigned char nonbondedGroupSize;
};
void cull_goodgroups(const CompAtom * __restrict p_1,
const int * __restrict glist,
int gu,
BigReal p_i_x, BigReal p_i_y, BigReal p_i_z,
BigReal groupplcutoff2,
int * __restrict goodglist)
{
int hu = 0;
int g = 0;
int jprev0 = glist[0];
int jprev1 = glist[1];
int j0, j1;
BigReal pj_x_0, pj_x_1, pj_y_0, pj_y_1, pj_z_0, pj_z_1;
BigReal t_0, t_1, r2_0, r2_1;
pj_x_0 = p_1[jprev0].position.x; pj_x_1 = p_1[jprev1].position.x;
pj_y_0 = p_1[jprev0].position.y; pj_y_1 = p_1[jprev1].position.y;
pj_z_0 = p_1[jprev0].position.z; pj_z_1 = p_1[jprev1].position.z;
g += 2;
for ( ; g < gu - 2; g += 2 ) {
j0 = jprev0;
j1 = jprev1;
t_0 = p_i_x - pj_x_0; t_1 = p_i_x - pj_x_1;
r2_0 = t_0 * t_0; r2_1 = t_1 * t_1;
t_0 = p_i_y - pj_y_0; t_1 = p_i_y - pj_y_1;
r2_0 += t_0 * t_0; r2_1 += t_1 * t_1;
t_0 = p_i_z - pj_z_0; t_1 = p_i_z - pj_z_1;
r2_0 += t_0 * t_0; r2_1 += t_1 * t_1;
jprev0 = glist[g];
jprev1 = glist[g + 1];
pj_x_0 = p_1[jprev0].position.x; pj_x_1 = p_1[jprev1].position.x;
pj_y_0 = p_1[jprev0].position.y; pj_y_1 = p_1[jprev1].position.y;
pj_z_0 = p_1[jprev0].position.z; pj_z_1 = p_1[jprev1].position.z;
bool test0 = (r2_0 < groupplcutoff2);
bool test1 = (r2_1 < groupplcutoff2);
goodglist[hu] = j0;
goodglist[hu + test0] = j1;
hu += test0 + test1;
}
}
Compiler command used:
----------------------
gcc -O3 -march=znver5 -fdump-tree-slp-details -fopt-info-vec-missed
-S namd556_goodglist_variant_ii.s namd556_goodglist_variant.ii 2>
gcc_vec_missed.txt
icx -O3 -march=graniterapids -S -Rpass=slp-vectorizer -o namd556_icx_ii.s
namd556_goodglist_variant.ii 2>icx_vect.log
Logs:
------
In the slp dump files when compiled with gcc we can see that the SLP discovery
failed.
The logs also substantiate that:
namd556_goodglist_variant.cpp:36:15: missed: couldn't vectorize loop
namd556_goodglist_variant.cpp:57:22: missed: not vectorized: unsupported use in
stmt.
In icx Rpass logs we can see the vectorization happened.
namd556_goodglist_variant.cpp:15:6: remark: SLP vectorized with cost -2 and
with tree size 7 [-Rpass=slp-vectorizer]
namd556_goodglist_variant.cpp:15:6: remark: SLP vectorized with cost -2 and
with tree size 7 [-Rpass=slp-vectorizer]
namd556_goodglist_variant.cpp:15:6: remark: SLP vectorized with cost -1 and
with tree size 13 [-Rpass=slp-vectorizer]