This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/82430] New: [4.9 Regression] Suboptimal code generated because of unnecessary "pxor xmm0, xmm0"
- From: "antoshkka at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 Oct 2017 14:30:36 +0000
- Subject: [Bug target/82430] New: [4.9 Regression] Suboptimal code generated because of unnecessary "pxor xmm0, xmm0"
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82430
Bug ID: 82430
Summary: [4.9 Regression] Suboptimal code generated because of
unnecessary "pxor xmm0, xmm0"
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
Target Milestone: ---
Following code snippets
unsigned my_mul(unsigned a) {
return a * 1.5;
}
unsigned my_div(unsigned a) {
return a / 1.5;
}
Generate assemblies that have "pxor xmm0, xmm0" as a first instruction:
my_mul(unsigned int):
pxor xmm0, xmm0 <=== This is not necessary
mov edi, edi
cvtsi2sdq xmm0, rdi
mulsd xmm0, QWORD PTR .LC0[rip]
cvttsd2si rax, xmm0
ret
my_div(unsigned int):
pxor xmm0, xmm0 <=== This is not necessary
mov edi, edi
cvtsi2sdq xmm0, rdi
divsd xmm0, QWORD PTR .LC0[rip]
cvttsd2si rax, xmm0
ret
The regression was introduced with GCC 4.9. GCC-4.8 and previous versions were
generating assembly without pxor:
my_mul(unsigned int):
mov edi, edi
cvtsi2sd xmm0, rdi
mulsd xmm0, QWORD PTR .LC0[rip]
cvttsd2si rax, xmm0
ret
my_div(unsigned int):
mov edi, edi
cvtsi2sd xmm0, rdi
divsd xmm0, QWORD PTR .LC0[rip]
cvttsd2si rax, xmm0
ret