This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 May 2010 20:16:04 -0000
- Subject: [Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
- References: <bug-44069-17521@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from rguenth at gcc dot gnu dot org 2010-05-12 20:16 -------
So, the issue is that the loop copying vals to m looks like
<bb 3>:
D.21310_23 = r_22 * 4;
D.21309_25 = D.21310_23 + c_24;
D.21308_26 = (long unsigned int) D.21309_25;
D.21305_29 = vals[0][D.21308_26];
m.m[D.21309_25] = D.21305_29;
c_30 = c_24 + 1;
<bb 4>:
# c_24 = PHI <c_32(7), c_30(3)>
if (c_24 <= 3)
goto <bb 3>;
else
goto <bb 5>;
<bb 5>:
r_31 = r_22 + 1;
<bb 6>:
# r_22 = PHI <0(2), r_31(5)>
if (r_22 <= 3)
goto <bb 7>;
else
goto <bb 8>;
<bb 7>:
# c_32 = PHI <0(6)>
goto <bb 4>;
where vals[0][D.21308_26] does not represent a use of vals[i][j] with
i > 0. This is because get_ref_base_and_extent restricts the valid
extent of D.21308_26 to 3. Note that the issue is exposed by
re-constructing an array-reference from the pointer access in the
inlined constructor. After inlining into main() we have
<bb 3>:
D.21310_23 = r_22 * 4;
D.21309_25 = D.21310_23 + c_24;
D.21308_26 = (long unsigned int) D.21309_25;
D.21307_27 = D.21308_26 * 8;
D.21306_28 = &vals[0][D.21308_26];
D.21305_29 = *D.21306_28;
m.m[D.21309_25] = D.21305_29;
c_30 = c_24 + 1;
from the non-inlined variant
<bb 4>:
D.21286_7 = r_1 * 4;
D.21287_8 = D.21286_7 + c_2;
D.21286_9 = r_1 * 4;
D.21287_10 = D.21286_9 + c_2;
D.21288_11 = (long unsigned int) D.21287_10;
D.21289_12 = D.21288_11 * 8;
D.21290_14 = arr_13(D) + D.21289_12;
D.21291_15 = *D.21290_14;
this_16(D)->m[D.21287_10] = D.21291_15;
c_17 = c_2 + 1;
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |middle-end
Keywords| |wrong-code
Summary|optimization bug |[4.5 Regression]
|initializing from cast array|optimization bug
| |initializing from cast array
Target Milestone|--- |4.5.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44069