From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 100AD3858D37; Fri, 3 Mar 2023 14:56:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 100AD3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677855380; bh=rlNq7jOzGErd9mBP+NAM3/yYoR5JHVVJRNPzCqB2X2E=; h=From:To:Subject:Date:From; b=XgSD9TeeXdCkdx8K4eMS8h9IogBB2+GY5T7ttTYo2sWQvgWhLthXYUVx9ciymGrtc ONy26dwXOIUPtXBbohS78aw9mW6R7mW7PF7EUdKjCakax+n28f1iyZ/httaeG8nNnE 1uSJN34MQt+8kB7Ej1iKb3Xl0bdL17JEvej1wTbk= From: "vincenzo.innocente at cern dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109011] New: missed optimization in presence of __builtin_ctz Date: Fri, 03 Mar 2023 14:56:19 +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: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincenzo.innocente at cern dot ch 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=3D109011 Bug ID: 109011 Summary: missed optimization in presence of __builtin_ctz Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vincenzo.innocente at cern dot ch Target Milestone: --- in the following code foo does not vectorize, bar does. clang vectorize foo using a pattern that invokes vplzcntd (code made a bit complex to make vectorization "relevant")=20 see https://godbolt.org/z/5fa1zbPeG #include uint32_t x[256]; uint32_t y[256]; uint32_t w[256]; uint32_t z[256]; void foo() { for (int i=3D0; i<256;i++) { auto p =3D x[i] ? __builtin_ctz(x[i]) : y[i]; z[i] =3D w[i]*p; }=20=20 } void bar() { for (int j=3D0; j<256;j+=3D8) for (int i=3Dj; i