From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 602433858C52; Mon, 6 Mar 2023 09:22:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 602433858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678094571; bh=HjFNNlxBwsD5FtBhvOcetP2yOuFUDnP1S/rxtOvfi8A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L6ReUoNK7RAhR+t8Y/3LGlmTjTxEgB/P0FHTzTW3JuXSJlk2YSAFi77XoJ44Jk8zE sXI2fZv9W9kMeX8Zs0+yjR8AiT0I3aNIHmQGkj4pGGw7TB/JXZAY8N9PkJEKFDXoW0 RnVGLANbfEvLFebw4F8nTME0H2dy7nSHTzF0rMv4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109011] missed optimization in presence of __builtin_ctz Date: Mon, 06 Mar 2023 09:22:50 +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: 12.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109011 --- Comment #17 from Jakub Jelinek --- Testcase for the normal SI -> SI stuff might be something like with e.g. -O3 -mavx512{bw,cd,vl,dq,bitalg,vpopcntdq} -mbmi -mlzcnt options or so (the intent of the last 2 is to make clz/ctz defined at zero = in GIMPLE). Plus similar testcase with long long * instead of int * and ll suffixed builtins. And also with unsigned char * and unsigned short * too eventually. void foo (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D __builtin_popcount (q[i]); } void bar (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D __builtin_clz (q[i]); } void baz (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D __builtin_ffs (q[i]); } void qux (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D __builtin_ctz (q[i]); } void corge (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D q[i] ? __builtin_clz (q[i]) : 32; } void grault (int *p, int *q) { for (int i =3D 0; i < 2048; ++i) p[i] =3D q[i] ? __builtin_ctz (q[i]) : 32; }=