[Bug target/62055] New: missed optimization: recognize fnabs (FP negative absolute value) (x86-64)
spatel at rotateright dot com
gcc-bugzilla@gcc.gnu.org
Thu Aug 7 19:17:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62055
Bug ID: 62055
Summary: missed optimization: recognize fnabs (FP negative
absolute value) (x86-64)
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: spatel at rotateright dot com
$ cat fnabs.c
#include <math.h>
float foo(float a) {
return -fabsf(a);
}
$ gcc49 -O1 fnabs.c -S -o -
.text
.globl _foo
_foo:
LFB19:
movss LC0(%rip), %xmm1
andps %xmm1, %xmm0
movss LC1(%rip), %xmm1
xorps %xmm1, %xmm0
ret
LFE19:
.literal16
.align 4
LC0:
.long 2147483647
.long 0
.long 0
.long 0
.align 4
LC1:
.long 2147483648
.long 0
.long 0
.long 0
---------------------------------------------------
That's a lot of constant pool data and instructions to turn on a single bit.
I think there are 2 steps to improving this. First, recognize that -(fabs(a))
can be transformed into an 'or' op:
movss LC0(%rip), %xmm1
orps %xmm1, %xmm0
LC0:
.long 2147483648
Second, I don't think we need the extra 0 longs here; movss only loads 4 bytes.
This may require understanding that the upper vector elements for the 'orps'
are don't cares?
More information about the Gcc-bugs
mailing list