This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82409] New: Superflous pxor instructions in the generated assembly.
- From: "maxim.yegorushkin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 02 Oct 2017 18:00:26 +0000
- Subject: [Bug c++/82409] New: Superflous pxor instructions in the generated assembly.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82409
Bug ID: 82409
Summary: Superflous pxor instructions in the generated
assembly.
Product: gcc
Version: 7.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: maxim.yegorushkin at gmail dot com
Target Milestone: ---
For the following function:
double f(int a, int b) {
return static_cast<double>(a - b) / (a + b);
}
g++-7.2 with flags "-O3 -std=c++14" generates the following code:
f(int, int):
pxor %xmm0, %xmm0
movl %edi, %eax
pxor %xmm1, %xmm1
subl %esi, %eax
addl %esi, %edi
cvtsi2sd %eax, %xmm0
cvtsi2sd %edi, %xmm1
divsd %xmm1, %xmm0
ret
Note pxor instructions in there to zero out the unused upper bits of xmm
registers. Are they necessary?
clang++-3.5 and newer generates similar code but without these pxor
instructions.