From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F1F37385BF81; Thu, 9 Apr 2020 19:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1F37385BF81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586459581; bh=QiSr4qwc3Q3fvQvl218NyA+m2ZPT03t+HJ7fQrjAsgE=; h=From:To:Subject:Date:From; b=p+ZfyUxn9m8W7YWYh/530WWi8Sq9MusingWcPHrZdaJ2KPR4yuUmy01RqOTS6sCzw dQX5DLdepErt+Sl4CYqovADX6c1X+PH2lfTDRt+hW1exDsOvkIiSNSWMeAoHdbbru5 DOaPDUsas9/MRkvUmUMoesRXqemaq42WVdL02weY= From: "rth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94543] New: missed optimization with MIN and AND with type promotion Date: Thu, 09 Apr 2020 19:13:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: tree-ssa X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rth 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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, 09 Apr 2020 19:13:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94543 Bug ID: 94543 Summary: missed optimization with MIN and AND with type promotion Product: gcc Version: tree-ssa Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: rth at gcc dot gnu.org Target Milestone: --- unsigned f(unsigned short x) { return (x > 0xff ? 0xff : x) & 0xff; } cmpw $255, %di movl $255, %eax cmova %eax, %edi movzwl %di, %eax ret The final AND is of course redundant. The optimizer removes it for wider types, but fails to do so when promoting from short.=