Summary: | Static (base/offset/size rule) should be extended to handle array elements | ||
---|---|---|---|
Product: | gcc | Reporter: | davidxl <xinliangli> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | gcc-bugs, rguenth |
Priority: | P3 | Keywords: | alias, missed-optimization |
Version: | 4.3.0 | ||
Target Milestone: | 4.9.0 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2010-07-13 10:55:27 | |
Bug Depends on: | |||
Bug Blocks: | 35358 |
Description
davidxl
2008-02-25 05:19:38 UTC
Confirmed. MEM_REF might help here as we'd get off_1 = IDX <0 + i * 8> MEM_REF <aa, off_1> and off_2 = IDX <4 + j * 8> MEM_REF <aa, off_2> where the alias-oracle should be able to see that the accesses cannot overlap. Zdeneks lim/store-motion rewrite should help as well. Re-confirmed. Here is another testcase that depends on PRE/FRE (really VN) getting the more correct answer: struct A{ int a; int b; }; struct A aa[100]; void foo(int n, int i, int j) { aa[j].a = 0; aa[i].b = 1; if (aa[j].a != 0) link_error(); } Test case of comment #4 still fails with r162134. Not sure what is expected for the test case of comment #0, but I'm assuming the point is that the store of the reduction should be sunk. That doesn't happen as of r162134, this is what comes out of the compiler at -O3: ;; Function foo (foo) Removing basic block 6 foo (int n, int i, int j) { int prephitmp.3; int k; int D.1988; <bb 2>: if (n_4(D) > 0) goto <bb 3>; else goto <bb 5>; <bb 3>: prephitmp.3_14 = aa[i_5(D)].a; <bb 4>: # k_16 = PHI <k_10(4), 0(3)> # prephitmp.3_18 = PHI <prephitmp.3_9(4), prephitmp.3_14(3)> D.1988_8 = aa[j_7(D)].b; prephitmp.3_9 = prephitmp.3_18 + D.1988_8; aa[i_5(D)].a = prephitmp.3_9; k_10 = k_16 + 1; if (k_10 != n_4(D)) goto <bb 4>; else goto <bb 5>; <bb 5>: return; } |