It can't sink stores at all due to some defects. For int foo(int *a, int r) { int ret = 0; *a = 1; if (r == 3) *a = 5; else ret = r + 20; return ret; }
the store to *a should be sunk into the else block. Likewise for int foo(int *a, int r, short *b) { int ret = 0; *a = 1; if (r == 3) *a = 5; else ret = r + 20; *b = 9; return ret; } for int foo(int *a, int r, short *b) { int ret = 0; *a = 1; switch (r) { case 3: *a = 5; break; case 4: case 5: *a = 9; ret = r + 25; break; default: ret = r + 20; } *b = 9; return ret; } it should go into the default case. I have a patch, but that requires the function exit to use .MEM. -- Summary: tree-ssa-sink does not really work Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41490