From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1AAE33858C56; Wed, 15 Nov 2023 14:09:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1AAE33858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700057383; bh=+7jKuIpFptrND2YMwgXYGErNrcMQqfMBaaNUFwyT30c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aKCNEfFvfSfl+e95DO+pmwNudmjRgyH9/nSxJxOZfq2b0/SgiEOGvZOHiyurCcB7S udnNs50XyWVLIdCnQU+1bzznjcR82KJKn8tHYDLsepaphq4SO9cGJ0NL0d+he95ff4 Qlcj9353e1QEw/FKn0bNMRWvItRAlw3Bnbt1UYnw= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109088] GCC does not always vectorize conditional reduction Date: Wed, 15 Nov 2023 14:09:42 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement 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: 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=3D109088 --- Comment #18 from Richard Biener --- Ah, so this is for int foo (int *a, int x) { int sum =3D 0; for (int i =3D 0; i < 1024; ++i) if (a[i] < 10) sum =3D sum + a[i] + x; return sum; } transforming it to int foo (int *a, int x) { int sum =3D 0; for (int i =3D 0; i < 1024; ++i) { tem =3D a[i] + x; if (a[i] < 10) sum =3D sum + tem; } return sum; } note this is re-associating and thus not always valid. It also executes stmts unconditionally (also not always valid, for FP spurious exceptions might be raised).=