From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EE8C1385DC0A; Wed, 29 Apr 2020 01:11:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE8C1385DC0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588122714; bh=ZIOThRRfp1cQj+Gk1o+070IMKuN0Zhf7/rH8TllsUTw=; h=From:To:Subject:Date:From; b=OlRu1DGb0zfXkD3lJpxall4cu/O5LVZxinh+NP7VIkNzOT723gwEDFmhVpNH2JXW+ GmGsvXON9nDLyFVTV79gHUmQsG4Wjsyw2qhQ14/s9svDmppRB0KMfS8KmyE0hqYCAJ zGte0J+2xXIfDD2oGuCwuJlswzKWcW7Aw7uyCxCE= From: "gabravier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/94837] New: Failure to optimize out spurious movbe into bswap Date: Wed, 29 Apr 2020 01:11:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gabravier at gmail dot 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: Wed, 29 Apr 2020 01:11:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94837 Bug ID: 94837 Summary: Failure to optimize out spurious movbe into bswap Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- float swapFloat(float x) { union { float f; uint32_t u32; } swapper; swapper.f =3D x; swapper.u32 =3D __builtin_bswap32(swapper.u32); return swapper.f; } For this function, on x86-64 with `-O3 -mmovbe`, LLVM outputs this :=20 swapFloat(float): # @swapFloat(float) movd eax, xmm0 bswap eax movd xmm0, eax ret GCC instead outputs this : swapFloat(float): movd DWORD PTR [rsp-4], xmm0 movbe eax, DWORD PTR [rsp-4] movd xmm0, eax ret It seems highly likely to me that a spill to memory is much slower than a direct `bswap`.=