http://llvm.org/bugs/show_bug.cgi?id=21962
Bug ID: 21962
Summary: FP constants not combined (fast-math)
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
$ cat fadd.c
double foo(double x, double y) {
return -( x + 1.0 + y + 2.0 );
}
Or as IR:
define double @foo(double %x, double %y) {
%add = fadd fast double %x, 1.000000e+00
%add1 = fadd fast double %add, %y
%add2 = fadd fast double %add1, 2.000000e+00
%sub = fsub fast double -0.000000e+00, %add2
ret double %sub
}
$ ./clang -march=haswell -O1 -ffast-math -fomit-frame-pointer fadd.c -S -o -
LCPI0_0:
.quad -4616189618054758400 ## double -1
LCPI0_1:
.quad -4611686018427387904 ## double -2
...
vmovsd LCPI0_0(%rip), %xmm2
vsubsd %xmm0, %xmm2, %xmm0
vsubsd %xmm1, %xmm0, %xmm0
vaddsd LCPI0_1(%rip), %xmm0, %xmm0
retq
-----------------------------------------------------------------------
This should be reassociated/combined to "-3.0 - x - y" (one constant, two
subtracts):
vmovsd LCPI0_0(%rip), %xmm2
vsubsd %xmm0, %xmm2, %xmm3
vsubsd %xmm1, %xmm3, %xmm0
retq
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs