https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111975
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-10-25 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Alex Coplan from comment #0) > 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; There's __SIZETYPE__ available for this (for portability) > 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]; It should be __MEM, not sure why that's not (longer?) dumped correctly. > 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). Yeah ... rename them > - the type vector(4) int isn't understood by the gimple FE. You need C frontend like typedefs, basically any not basic type needs to be manually declared (we don't output type declarations when dumping) > 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 Ah, it's a TARGET_MEM_REF! Parsing that isn't supported. I suggest to dump before IVOPTs instead. > > . 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. I'll make TARGET_MEM_REF supported.