From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AD1F23858C41; Fri, 3 Nov 2023 07:20:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD1F23858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698996016; bh=fqtmE22ntteAVoig71qoP/cuTOTWpnoIptbBRuNEgn0=; h=From:To:Subject:Date:From; b=oMTjEfw1+RVQUCNNXHTzLk/Ev4vCzRb8X8XrLvPCcVMpCtt8xGUbxdzdw5qX2rb4i ecRfOBC1oxLdVlc2DINZUvhqhrz6PtrJc05wIUhj44VlD50/c/ip7B3xAU6z3FcBWJ J7mkdeb9vfhQ9Mmng20n9A3k45PJR5khBj2lKzNU= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112361] New: [14 Regression] avx512f-reduce-op-1.c miscompiled since r14-5076 Date: Fri, 03 Nov 2023 07:20:16 +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: 14.0 X-Bugzilla-Keywords: 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: 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=3D112361 Bug ID: 112361 Summary: [14 Regression] avx512f-reduce-op-1.c miscompiled since r14-5076 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- Since r14-5076-g01c18f58d37865d5f3bbe93e666183b54ec608c7 I see gcc.target/i386/avx512f-reduce-op-1.c execution failure. Reduced -O2 -mavx512f: __attribute__((noipa)) float foo (void) { float a[16] =3D { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4 }; float r3 =3D 0.0f; for (int i =3D 0; i < 16; i++) if ((1 << i) & 0xA6BA) r3 =3D r3 + a[i]; return r3; } int main () { if (foo () !=3D 37.0f) __builtin_abort (); } where before r14-5076 r3 has been correctly computed as 37.0f, but starting with r14-5076 it is 64.0f, i.e. the masking is ignored and all elements are added, not just the ones under the mask. The ifcvt dump has _1 =3D 42682 >> i_31; _2 =3D _1 & 1; _24 =3D _2 !=3D 0; _3 =3D a[i_31]; _ifc__43 =3D .COND_ADD (_24, r3_29, _3, r3_29); which I assume is correct, and vect dump shows computation of the mask but = then instead of using masked addition and at the end of loop reduction (well, ca= n we vectorize it at all without -ffast-math?) it scalarizes the addition but doesn't actually conditionalize it. Note, with -O2 -mavx512f -ffast-math t= he .COND_ADD is actually vectorized and so correctly returns 37.0f.=