https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111972
Bug ID: 111972
Summary: [14 regression] missed vectorzation for bool a = j !=
1; j = (long int)a;
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: crazylht at gmail dot com
Target Milestone: ---
cat test.c
double
foo() {
long n3 = 3450000, xtra = 7270;
long i,ix;
long j;
double Check;
/* Section 3, Conditional jumps */
j = 0;
{
for (ix=0; ix<xtra; ix++)
{
for(i=0; i<n3; i++)
{
if(j==1) j = 2;
else j = 3;
if(j>2) j = 0;
else j = 1;
if(j<1) j = 1;
else j = 0;
}
}
}
Check = Check + (double)j;
return Check;
}
The different between gcc 13 dump and gcc14 dump is
GCC13 we have
<bb 3> [local count: 1063004411]:
# i_16 = PHI <i_13(8), 0(5)>
# j_18 = PHI <_7(8), j_21(5)>
# ivtmp_15 = PHI <ivtmp_6(8), 3450000(5)>
_7 = j_18 ^ 1;
i_13 = i_16 + 1;
ivtmp_6 = ivtmp_15 - 1;
if (ivtmp_6 != 0)
goto <bb 8>; [99.00%]
else
goto <bb 4>; [1.00%]
GCC14 we have
<bb 3> [local count: 1063004410]:
# i_17 = PHI <i_13(8), 0(5)>
# j_19 = PHI <_14(8), j_22(5)>
# ivtmp_16 = PHI <ivtmp_15(8), 3450000(5)>
_9 = j_19 != 1;
_14 = (long int) _9;
i_13 = i_17 + 1;
ivtmp_15 = ivtmp_16 - 1;
if (ivtmp_15 != 0)
goto <bb 8>; [98.99%]
else
goto <bb 4>; [1.01%]
Vectorizer can handle
_7 = j_18 ^ 1;
but not
_9 = j_19 != 1;
_14 = (long int) _9;
../test.C:11:18: note: vect_is_simple_use: operand j_19 != 1, type of def:
internal
../test.C:11:18: note: mark relevant 2, live 0: _9 = j_19 != 1;
../test.C:11:18: note: worklist: examine stmt: _9 = j_19 != 1;
../test.C:11:18: note: vect_is_simple_use: operand j_19 = PHI <_14(8),
j_22(5)>, type of def: unknown
../test.C:11:18: missed: Unsupported pattern.
../test.C:15:6: missed: not vectorized: unsupported use in stmt.
../test.C:11:18: missed: unexpected pattern.
The difference comes from phiopt2.