From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25811 invoked by alias); 4 Apr 2014 11:37:25 -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 25780 invoked by uid 48); 4 Apr 2014 11:37:21 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/59429] Missed optimization opportunity in qsort-style comparison functions Date: Fri, 04 Apr 2014 11:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: ktietz 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 cc 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-04/txt/msg00289.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59429 Kai Tietz changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-04-04 CC| |ktietz at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #4 from Kai Tietz --- This issue seems to be another problem caused by missing unification of expressions. For given example we get for 'comGE' the following gimple: comGE (int a, int b) { int iftmp.8_1; int _2; _Bool _6; int _7; : if (a_3(D) <= b_4(D)) goto ; else goto ; : _6 = a_3(D) != b_4(D); _2 = (int) _6; _7 = -_2; : # iftmp.8_1 = PHI <_7(3), 1(2)> return iftmp.8_1; } As we see we don't optimize out the negate case. For expression: (a_3(D) > b_4(D) ? 1 : -((int) (a_3(D) != b_4(D)))) we should transform it instead to: (a_3(D) < b_4(D) ? -1 : (int) (a_3(D) != b_4(D))) The reference to gold's --icf option looks for me wrong here. Such optimizations - as done here for gold - can't be done by gcc. At least not for the given example provided. In other TUs there always might users of direct function-address in comparison. So to find and reduce identical code-blocks is just a linker feature (with some danger IMHO). So back to this issue. I would think it is more a problem to be solved on gimple, and not that much a RTL issue in first hand.