http://llvm.org/bugs/show_bug.cgi?id=20728
Bug ID: 20728
Summary: APFloat::fusedMultiplyAdd is broken, leading to
incorrect constant folding for libc fmal calls.
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Support Libraries
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
APFloat::multiplySignificand generates incorrect results when called with
Addend != 0 (i.e. from APFloat::fusedMultiplyAdd). This results in incorrect
results from libc fmal calls with constant arguments. I have tested this X86,
but I believe it will hit any architecture that uses APFloat to handle long
double constants.
The output is only incorrect for some constants.
E.g. fmal(3.0L, 4.0L, 5.0L) == 1.0 instead of 17.0L.
However fmal(-3.0L, 4.0L, 5.0L) == -7.0L as expected.
Compiling the following program with 'clang -O3 -o foo foo.c' on X86
demonstrates the bug:
#include <math.h>
#include <stdio.h>
int main(void) {
printf("%Lf\n", fmal(3.0L, 4.0L, 5.0L));
return 0;
}
The misbehavior for the specific constants above was introduced by r181715. The
commit message for that revision was: "Fix a bug that
APFloat::fusedMultiplyAdd() mistakenly evaluate "14.5f * -14.5f + 225.0f" to
225.0f.". I have confirmed that rolling back to r181714 causes "fmal(3.0L,
4.0L, 5.0L)" to generate correct results, but breaks "14.5f * -14.5f + 225.0f".
--
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