https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126976
Bug ID: 126976
Summary: forwprop introduce the result divergence
Product: gcc
Version: 16.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: kyuwoncho18 at gmail dot com
Target Milestone: ---
Created attachment 65380
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65380&action=edit
same code as I include on description
Consider the code:
#include <stdio.h>
typedef signed char v8qi __attribute__((vector_size(8)));
typedef unsigned char v8uqi __attribute__((vector_size(8)));
typedef short v8hi __attribute__((vector_size(16)));
__attribute__((noipa))
v8hi f(v8qi A, v8qi B) {
v8uqi Au = (v8uqi)A;
v8hi r = { Au[0], Au[1], Au[2], Au[3], B[4], B[5], B[6], B[7] };
return r;
}
int main(void) {
v8qi A = { -1, -2, 3, 4, 5, 6, 7, 8 };
v8qi B = { 10, 20, 30, 40, -50, -60, -70, -128 };
v8hi r = f(A, B);
short out[8];
__builtin_memcpy(out, &r, sizeof out);
for (int i = 0; i < 8; i++) printf("%d ", out[i]);
printf("\n");
return 0;
}
And with O0, it prints "255 254 3 4 -50 -60 -70 -128", but with O2, it prints
"255 254 3 4 206 196 186 128".
Godbolt: https://godbolt.org/z/jj1ba1584
Only affected after GCC 16.1; on 15.3, it can not be reproduced.