From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D90C3858402; Wed, 13 Sep 2023 09:46:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D90C3858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694598379; bh=DtFeOJZwE21rKOYr1t6aFp6Jl8EIT+E/XCh6kEJPiO4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ys/iJOExLGlKVzle+yetue2bUjD66yyvt0J1wVJHM/mJlu2W/7Z4wJ4gT3NLLYcFl bJr7bCeix5S5GgqrTP1JQWRegQDWNDctomokxLatVmZzl3If+gZR+ig1M7Yu/8ygVc bEX95p+urCDxcOfpDbQK1hRfdnhxzNHEx/QhdkKU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/111401] Middle-end: Missed optimization of MASK_LEN_FOLD_LEFT_PLUS Date: Wed, 13 Sep 2023 09:46:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: everconfirmed bug_status cf_reconfirmed_on 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=3D111401 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2023-09-13 --- Comment #1 from Richard Biener --- The vectorizer sees if-converted code like [local count: 955630224]: # init_20 =3D PHI <_36(8), init_12(D)(18)> # i_22 =3D PHI _1 =3D (long unsigned int) i_22; _2 =3D _1 * 4; _3 =3D cond_15(D) + _2; _4 =3D *_3; _23 =3D _4 !=3D 0; _6 =3D _1 * 8; _38 =3D _37 + _6; _7 =3D (double *) _38; _8 =3D .MASK_LOAD (_7, 64B, _23); _ifc__35 =3D _23 ? _8 : 0.0; _36 =3D init_20 + _ifc__35; i_18 =3D i_22 + 1; if (n_13(D) > i_18) so what it produces matches up here. There's the possibility to modify the if-conversion handling to use a COND_ADD instead of the COND_EXPR plus ADD, I think that would be the best thing here. See tree-if-conv.cc:is_cond_scalar_reduction/convert_scalar_cond_reduction I think this is also wrong code when signed zeros are involved.=