From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 551623858C2B; Thu, 9 Nov 2023 12:45:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 551623858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699533954; bh=SMUjeriu9GI+PF3XUGfWqNfor0ZqSiQSFXKweSEPc3Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FKy3x/kVDu6icPeoiQ6km8vzF9iGGKcnEM/69bDYesSRrgwP4ugHn0zaJarWjpFRI KpWAGTUus+xVYOgtnfx/NpWGNvkIUWEn4W98XNXfhz+dEyvbdBALM9hMtV8JLlMOuK 0DhY4iTy8T1wBnWy3VYa1ktSsgbLZvuoc9tqm/oU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112457] Possible better vectorization of different reduction min/max reduction Date: Thu, 09 Nov 2023 12:45:54 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: component blocked 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=3D112457 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c |tree-optimization Blocks| |53947 --- Comment #2 from Richard Biener --- Well, this is because MAX_EXPR detection fails when store motion inserts fl= ags (the max =3D max is elided) to avoid store-data races. Also when using -Ofast we avoid this but then the next phiopt comes too late to discover MAX after store motion is applied. The more practical example is int foo2 (int max, int n, int * __restrict a) { for (int i =3D 0; i < n; ++i) if (max < a[i]) { max =3D a[i]; } return max; } and that's handled OK. For your second example, index reduction, there's already bugreports. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations=