From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 17DAE385BF81; Thu, 16 Apr 2020 13:11:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17DAE385BF81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587042680; bh=N2Q8xNoG7f2WMrKV+/Bx3sMhjJRW8OS9cbH7vTOYMLk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B6TtNbot3CFUEaPl01lkQUtZNn26DBC6UH/lGDFlsd9s45+B00x4bgmfNVN1emTQ2 DIHChC62MGvCe6JXKMKY4dzyqlNTjj6fyztdDcEj6Vw7zxhRhJ+sBq/ceZ/rCJ8oi0 FHoOGo7DStdrsO+O4aD6gWmJm58ZltZoLGQ9/8lY= From: "rguenth 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 13:11:20 +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: 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: 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 13:11:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94617 --- Comment #7 from Richard Biener --- (In reply to Jakub Jelinek from comment #6) > (In reply to David Seifert from comment #5) > > just benchmarked the code on an oldish Ivybridge. GCC with vanilla_band= pass > > is 2.1x slower than GCC with funky_bandpass, and GCC with funky_bandpas= s is > > 12% slower than Clang with vanilla_bandpass. >=20 > 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 branch= es > if there are (if well, then branches are significantly faster, if they are > very badly predictable, then conditional moves are faster). >=20 > 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. sure, there are extra constraints that a <=3D b and the unsigned type has to have 1 bit more precision. So if we would want to do this transform then we'd need symbolic range info constraining a and b appropriately.=