From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0563C385B835; Thu, 16 Apr 2020 12:17:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0563C385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587039461; bh=yjnA81Y0X1VdX9V9pagRJJRh8DHHskwn5iNlUNqDh0c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UltyzjdpL4Gnpa/MpsKAuABHpJicZiD3sIiSOBCvuPGcerOSGtBbgK/Qwc9eLHPK1 JjNEgu/Qlu7R0RYbJHUrbLHMILIkI7QrX+RDolBnY1DXR6+lzFYPYr11A0jHYPdRhu 19jVEmx5rFKGxHNJBAWwf0SLwB8kUt89vpYrniWw= 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 12:17:40 +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 12:17:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94617 --- Comment #4 from Richard Biener --- IIRC you can also express the range test this way: const char* vanilla_bandpass(int a, int b, int x, const char* low, const ch= ar* high) { const bool within_interval { (unsigned long)x - a < (unsigned long)b - a = }; return (within_interval ? high : low); } which gives you _Z16vanilla_bandpassiiiPKcS0_: .LFB0: .cfi_startproc movslq %edi, %rdi movslq %edx, %rdx movslq %esi, %rsi movq %rcx, %rax subq %rdi, %rdx subq %rdi, %rsi cmpq %rsi, %rdx cmovb %r8, %rax ret=