From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16963 invoked by alias); 16 Dec 2014 10:11:10 -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 16930 invoked by uid 48); 16 Dec 2014 10:11:05 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/64322] More optimize opportunity for constant folding Date: Tue, 16 Dec 2014 10:11: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: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: bug_status cf_reconfirmed_on everconfirmed 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: 2014-12/txt/msg01855.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64322 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-12-16 Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- Well, I rather wonder how the store to an otherwise unused value can affect the code. It doesn't on the GIMPLE level. I suppose RTL somehow invalidly thinks that after b = 0; c = 0; b is still zero (so it only considers the two volatiles aliasing but doesn't consider the b volatile). It seems to be combine optimizing the case with c = 0, not sure why it doens't with c = 0x1000000L. Ah, the large constant is split to a reg. Difference: -Successfully matched this instruction: -(set (reg:DI 98) - (ashift:DI (reg:DI 94 [ D.1849 ]) - (const_int 1 [0x1]))) -Successfully matched this instruction: -(set (reg:DI 97 [ a ]) - (const_int 0 [0])) -allowing combination of insns 10, 11 and 12 -original costs 4 + 3 + 0 = 0 -replacement costs 6 + 4 = 10 -deferring deletion of insn with uid = 10. -modifying insn i2 11: {r98:DI=r94:DI<<0x1;clobber flags:CC;} Otherwise I agree with Jakub that VRP should be enhanced (it's weak with handling non-initeger-VR_RANGES for most codes). But combine probably exposes a RTL simplification so I wonder if we can add a similar one (after figuring out which one applies) on the GIMPLE level. Confirmed (at -O2 both codes are bad).