From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0F7D43858D33; Thu, 18 Jan 2024 17:34:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F7D43858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705599285; bh=sAM8wN8Mkbi7fHtbPb8nmSvwvWYUXucqYJJ5JVL8uVo=; h=From:To:Subject:Date:From; b=eOGJUOlc8GwbF/GrHbnQ0O2Gb6tKWu6iF3NhFEZ/lG6Ys6sIsaaoqDyE44pefdrVd Ga5cOWwTxFk38/Vw0hQjofGRByB4R/V+fAQylyCaDmSIAJ6N0upjI+X4wNj52NryZq fC/FIEtZQP5PF02mSHEPN0OjaGFseAdHo/hftmMs= From: "xxs_chy at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113487] New: Missed optimization:simplify demanded bits on multi-use instructions like select Date: Thu, 18 Jan 2024 17:34:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xxs_chy at outlook dot com 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113487 Bug ID: 113487 Summary: Missed optimization:simplify demanded bits on multi-use instructions like select Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xxs_chy at outlook dot com Target Milestone: --- Godbolt example: https://godbolt.org/z/EfKrTbK77 Based on common demanded bits from s&8 and s&16, ``` void src(bool c, unsigned a, unsigned b) { unsigned s =3D c ? a & 24 : b & 25; use(s & 8); use(s & 16); } ``` can be folded to: ``` void tgt(bool c, unsigned a, unsigned b) { unsigned s =3D c ? a : b ; use(s & 8); use(s & 16); } ``` Both LLVM and GCC missed this optimization opportunity.=