https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111975
Bug ID: 111975 Summary: gimple front end can't round-trip vectorized code Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- Take the following testcase on aarch64: void foo(int *restrict a, int *restrict b, int *restrict c) { for (int i = 0; i < 256; i++) a[i] = b[i] + c[i]; } compiled with -O2 -fdump-tree-optimized-gimple, we get the IR: void __GIMPLE (ssa,guessed_local(10737416)) foo (int * restrict a, int * restrict b, int * restrict c) { sizetype ivtmp.17; vector(4) int vect__8.10; vector(4) int vect__6.9; vector(4) int vect__4.6; __BB(2,guessed_local(10737416)): goto __BB3(precise(134217728)); __BB(3,loop_header(1),guessed_local(687194626)): ivtmp.17_23 = __PHI (__BB3: ivtmp.17_19, __BB2: 0ul); vect__4.6_9 = MEM <vector(4) int> [(int *)b_12(D) + ivtmp.17_23 * 1]; vect__6.9_27 = MEM <vector(4) int> [(int *)c_13(D) + ivtmp.17_23 * 1]; vect__8.10_28 = vect__4.6_9 + vect__6.9_27; MEM <vector(4) int> [(int *)a_14(D) + ivtmp.17_23 * 1] = vect__8.10_28; ivtmp.17_19 = ivtmp.17_23 + 16ul; if (ivtmp.17_19 != 1024ul) goto __BB3(guessed(132120577)); else goto __BB4(guessed(2097151)); __BB(4,guessed_local(10737416)): return; } but trying to compile this with -fgimple shows several problems: - the type sizetype isn't known. - ivtmp.17 isn't accepted as a variable name (indeed none of the variables with . in the name are accepted). - the type vector(4) int isn't understood by the gimple FE. If I fix these issues by declaring the types as follows: typedef unsigned long sizetype; typedef int __attribute__((vector_size(16))) V; and substituting all uses of the old type names, and also rename all variables to replace . with _, then it is nearly accepted. One remaining problem seems to be that the MEM syntax isn't accepted: vect__4_6_9 = MEM <V> [(int *)b_12(D) + ivtmp_17_23 * 1]; gives: error: 'MEM' undeclared (first use in this function) and attempting to convert the MEM to use something closer to the syntax in the gcc.dg/gimplefe-* tests, this still fails: vect__4_6_9 = __MEM <V> ((int *)b_12(D) + ivtmp_17_23 * 1); is rejected with: error: expected ')' before '*' token . It would be good if these issues could be fixed so that optimized gimple can be round-tripped without laborious manual fixing of the input. Even with that, it's still not clear how to make the MEM expressions here get accepted.