------- Additional Comments From rguenth at gcc dot gnu dot org 2005-02-09 11:15 ------- Another testcase is the following:
xtern void link_error(void); void foo(int i) { int a[4]; if ((char*)&a[1] + 4*i + 4 != (char*)&a[i+2]) link_error(); if (&a[1] + i + 1 != &a[i+2]) link_error(); } which I have a patch for that works for C++ by extending the existing try_move_mult_to_index and trying to avoid inserting (unsinged) casts there. Unfortunately, for C (whose initial trees do not contain ARRAY_REF exprs), the frontend already inserts casts to unsigned (.03.generic): foo (i) { charD.1 * a.0D.1129; intD.0 D.1130; charD.1 * D.1131; charD.1 * D.1132; charD.1 * D.1133; unsigned intD.3 i.1D.1134; unsigned intD.3 D.1135; intD.0 * D.1136; intD.0 * D.1137; intD.0 * D.1138; charD.1 * D.1139; intD.0 aD.1128[4]; a.0D.1129 = (charD.1 *) &aD.1128; D.1130 = iD.1125 * 4; D.1131 = (charD.1 *) D.1130; D.1132 = a.0D.1129 + D.1131; D.1133 = D.1132 + 8B; i.1D.1134 = (unsigned intD.3) iD.1125; D.1135 = i.1D.1134 * 4; D.1136 = (intD.0 *) D.1135; D.1137 = &aD.1128 + D.1136; D.1138 = D.1137 + 8B; D.1139 = (charD.1 *) D.1138; if (D.1133 != D.1139) { link_error (); } else { } if (0) { link_error (); } else { } } which maybe even wrong, if not hindering optimizations at least. -- What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2005-02-07 19:30:41 |2005-02-09 11:15:29 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807