From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103534 invoked by alias); 19 May 2015 09:21:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 103392 invoked by uid 48); 19 May 2015 09:21:15 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65752] Too strong optimizations int -> pointer casts Date: Tue, 19 May 2015 09:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg01448.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #14 from Richard Biener --- (In reply to Chung-Kil Hur from comment #13) > Hi, I have the following modified code. > > #include > #include > #include > > int main() { > int x = 0, *p = 0; > uintptr_t i; > uintptr_t j = (uintptr_t) &x; > uintptr_t k = j+j; > uintptr_t l = 2*j - j - j; > for (i = j+j-k+l; ; i++) { > if (i == (uintptr_t)&x) { p = (int*)i; break; } > } > *p = 15; > > printf("%d\n", x); > } > > This example still prints out "0" instead of "15". > In this example, it seems that the integer "j+j-k+l" has no provenance. > It is unclear to me how the provenance is calculated. > Is there any concrete rule for calculating provenance? early PTA computes p_13, points-to non-local, points-to vars: { D.2349 } p_13 = (intD.6 *) i_1; *p_13 = 15; x.1_15 = xD.2349; while late PTA has an IL with just the equivalency (the rest is optimized away) p_6, points-to non-local, points-to NULL, points-to vars: { } j_4 = (uintptr_t) &x; : # i_1 = PHI <0(2), i_5(5)> if (i_1 == j_4) goto ; else goto ; : p_6 = (int *) i_1; *p_6 = 15; x.1_8 = x; so it hits essentially the same issue (the testcase is equivalent to the original one).