https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115355
Bug ID: 115355 Summary: PPCLE: Auto-vectorization creates wrong code for Power9 Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jens.seifert at de dot ibm.com Target Milestone: --- Input setToIdentity.C: #include <stdlib.h> #include <memory.h> #include <stdio.h> void setToIdentityGOOD(unsigned long long *mVec, unsigned int mLen) { for (unsigned long long i = 0; i < mLen; i++) { mVec[i] = i; } } void setToIdentityBAD(unsigned long long *mVec, unsigned int mLen) { for (unsigned int i = 0; i < mLen; i++) { mVec[i] = i; } } unsigned long long vec1[100]; unsigned long long vec2[100]; int main(int argc, char *argv[]) { unsigned int l = argc > 1 ? atoi(argv[1]) : 29; setToIdentityGOOD(vec1, l); setToIdentityBAD(vec2, l); if (memcmp(vec1, vec2, l*sizeof(vec1[0])) != 0) { for (unsigned int i = 0; i < l; i++) { printf("%llu %llu\n", vec1[i], vec2[i]); } } else { printf("match\n"); } return 0; } Fails gcc -O3 -mcpu=power9 -m64 setToIdentity.C -save-temps -fverbose-asm -o pwr9.exe -mno-isel Good: gcc -O3 -mcpu=power8 -m64 setToIdentity.C -save-temps -fverbose-asm -o pwr8.exe -mno-isel "-mno-isel" is only specified to reduce the diff. Failing output: pwr9.exe 0 0 1 1 2 0 3 4294967296 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 4th element contains wrong data.