From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11677 invoked by alias); 11 Jul 2014 17:47:49 -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 11241 invoked by uid 48); 11 Jul 2014 17:47:27 -0000 From: "matz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/61757] [4.10 Regression] genmodes failure with enable-checking Date: Fri, 11 Jul 2014 17:47: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.10.0 X-Bugzilla-Keywords: build X-Bugzilla-Severity: normal X-Bugzilla-Who: matz at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.10.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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-07/txt/msg00723.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61757 --- Comment #17 from Michael Matz --- The testsuite failure on m68k is indeed caused by r212352. In particular this hunk: @@ -1641,8 +1609,7 @@ record_equality (tree x, tree y) long as we canonicalize on one value. */ if (is_gimple_min_invariant (y)) ; - else if (is_gimple_min_invariant (x) - || (loop_depth_of_name (x) <= loop_depth_of_name (y))) + else if (is_gimple_min_invariant (x)) prev_x = x, x = y, y = prev_x, prev_x = prev_y; else if (prev_x && is_gimple_min_invariant (prev_x)) x = y, y = prev_x, prev_x = prev_y; The test is <=, so without loops (both SSA names being at 'depth' 0) the check succeeds always and hence will canonicalize on x (i.e. record x as value of y). The testcase is written so that this is the expected order for the third if to be found trivial. The problem doesn't happen on x86-64 because with -O1 the && condition is rewritten into arithmetic on '&', so even though the wanted transformation doesn't happen there are only two 'if ' statements, which is what is searched for. Unfortunately this is all harmless and not causing the miscompilations, it's only a missed optimization. FWIW, I think the canonicalization that DOM wants here should be retained in some form (canonicalize to the value that covers a larger area). Possibly by checking if one definition dominates the other