From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF1FB3858C3B; Sun, 29 Aug 2021 12:30:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF1FB3858C3B From: "jens.seifert at de dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102117] New: s390: Inefficient code for 64x64=128 signed multiply for <= z13 Date: Sun, 29 Aug 2021 12:30:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 8.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jens.seifert at de dot ibm.com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 12:30:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102117 Bug ID: 102117 Summary: s390: Inefficient code for 64x64=3D128 signed multiply for <=3D z13 Product: gcc Version: 8.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jens.seifert at de dot ibm.com Target Milestone: --- __int128 imul128(long long a, long long b) { return (__int128)a * (__int128)b; } creates sequence with 3 multiplies: _Z7imul128xx: .LFB0: .cfi_startproc ldgr %f2,%r12 .cfi_register 12, 17 ldgr %f0,%r13 .cfi_register 13, 16 lgr %r13,%r3 mlgr %r12,%r4 srag %r1,%r3,63 msgr %r1,%r4 srag %r4,%r4,63 msgr %r4,%r3 agr %r4,%r1 agr %r12,%r4 stmg %r12,%r13,0(%r2) lgdr %r13,%f0 .cfi_restore 13 lgdr %r12,%f2 .cfi_restore 12 br %r14 .cfi_endproc The following sequence only requires 1 multiply: __int128 imul128_opt(long long a, long long b) { unsigned __int128 x =3D (unsigned __int128)(unsigned long long)a; unsigned __int128 y =3D (unsigned __int128)(unsigned long long)b; unsigned long long t1 =3D (a >> 63) & a; unsigned long long t2 =3D (b >> 63) & b; unsigned __int128 u128 =3D x * y; unsigned long long hi =3D (u128 >> 64) - (t1 + t2); unsigned long long lo =3D (unsigned long long)u128; unsigned __int128 res =3D hi; res <<=3D 64; res |=3D lo; return (__int128)res; } _Z11imul128_optxx: .LFB1: .cfi_startproc ldgr %f2,%r12 .cfi_register 12, 17 ldgr %f0,%r13 .cfi_register 13, 16 lgr %r13,%r3 mlgr %r12,%r4 lgr %r1,%r3 srag %r3,%r3,63 ngr %r3,%r1 srag %r1,%r4,63 ngr %r4,%r1 agr %r3,%r4 sgrk %r3,%r12,%r3 stg %r13,8(%r2) lgdr %r12,%f2 .cfi_restore 12 lgdr %r13,%f0 .cfi_restore 13 stg %r3,0(%r2) br %r14 .cfi_endproc=