From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CEA2F385DC1B; Thu, 16 Apr 2020 12:47:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEA2F385DC1B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587041231; bh=ha2gHZsCPIN7GgspVnYl9RmbuHKqrdKfoNm1fasi9IM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PbnP5TD/6AD8jBbklJ5CZB73xYWkcPjmbIdXlXD6fU4bvRhSh9V9VmKk76JVHmlp1 Q4st+5Al2aYDhbzMAkUOvo9QMB6auJcTtNIjGbBuJqfRXo0QcQESYVR7ARrfQxIKGg dGPxm5ovZvbOWYjtrMQ/xLxcX1VzcFQ9zO6G7R7U= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94617] Simple if condition not optimized Date: Thu, 16 Apr 2020 12:47:11 +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: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2020 12:47:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94617 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- (In reply to David Seifert from comment #5) > just benchmarked the code on an oldish Ivybridge. GCC with vanilla_bandpa= ss > is 2.1x slower than GCC with funky_bandpass, and GCC with funky_bandpass = is > 12% slower than Clang with vanilla_bandpass. It really depends, conditional moves are really badly implemented in x86 and sometimes they do improve speed and at other times they slow things down by huge amounts, which mostly depends on how well the CPU can predict branches= if there are (if well, then branches are significantly faster, if they are very badly predictable, then conditional moves are faster). As for turning it into (unsigned)x - a < (unsigned)b - a reassoc has optimize_range_tests_var_bound which right now handles a >=3D 0 && a < b into (unsigned) a < (unsigned) b a >=3D 0 && a <=3D b into (unsigned) a <=3D (unsigned) b Now a >=3D b && a < c into (unsigned) a - b < (unsigned) c - b isn't equivalent to that, e.g. if b is 5 and c 4.=