From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 180243858D35; Tue, 18 Apr 2023 10:57:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 180243858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681815464; bh=XwKV2QKlc1o605kr6r1NjrR6RjoRO7yfO9qVgHikATg=; h=From:To:Subject:Date:From; b=ezUvIzw+gHtgZije2uHYEAC71tRu+suJZ8uWXnvQ5Fcwqa6LHCGwsAQMTbT9p2jXY hndiWHL3/NvPexI8Q6hBpoJLnrlRa74Yk56tsuxHGDa+82GRgbhOhcNpq4hdnHd08F FzLcTgqmmPKQj8YsTw1Lgc7LSVghRUMGrxxunZGw= From: "avieira at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109543] New: Avoid using BLKmode for unions with a non-BLKmode member when possible Date: Tue, 18 Apr 2023 10:57:43 +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: avieira 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=3D109543 Bug ID: 109543 Summary: Avoid using BLKmode for unions with a non-BLKmode member when possible Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: avieira at gcc dot gnu.org Target Milestone: --- Hi, So with the following C-code: $ cat t.c #include #ifdef GOOD typedef float64x2x2_t TYPE; #else typedef union { float64x2x2_t v; double d[4]; } TYPE; #endif void foo (TYPE *a, TYPE *b, TYPE *c, unsigned n) { TYPE X =3D a[0]; TYPE Y =3D b[0]; TYPE Z =3D c[0]; for (unsigned i =3D 0; i < n; ++n) { TYPE temp =3D X; X =3D Y; Y =3D Z; Z =3D temp; } a[0] =3D X; b[0] =3D Y; c[0] =3D Z; } If compiled for aarch64 with -DGOOD the compiler will use vector register m= oves in the loop, whereas without -DGOOD it will use the stack with memmoves. The reason for this is because when picking the mode to address a UNION with gcc will always choose BLKmode as soon as any member of a UNION is BLKmode.= In such cases I think it would be safe to go with not-BLKmode of members that = have the same size as the entire UNION?=