llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

APFloat::fusedMultiplyAdd is broken when addend is 0

Open gregbedwell opened this issue 12 years ago • 2 comments

Bugzilla Link 20832
Resolution FIXED
Resolved on Oct 14, 2014 14:40
Version trunk
OS All
CC @adibiagio,@hfinkel,@rotateright

Extended Description

I believe the following testcase demonstrates a bug in APFloat::fusedMultiplyAdd. I would expect this to produce a result of 56 ((7*8)+0) but instead it produces 7. The addend being 0 seems to be the key.


declare double @​llvm.fma.f64(double, double, double) nounwind

define double @​_Z4testv() nounwind { %1 = call double @​llvm.fma.f64(double 7.000000e+00, double 8.000000e+00, double 0.000000e+00) ret double %1 }

Using r216885: llc test.ll -mtriple=x86_64-unknown-unknown -o -

we get the following constant generated: .quad 4619567317775286272 # double 7

Within the function APFloat::fusedMultiplyAdd it calls multiplySpecials which returns opOK allowing the call to addOrSubtract to occur, however at no point is the actual multiplication performed, meaning that we essentially do 7+0, ignoring the multiplicand entirely.

gregbedwell avatar Sep 02 '14 10:09 gregbedwell

Should be fixed by r219708.

Thanks Hal!

adibiagio avatar Oct 14 '14 21:10 adibiagio

Should be fixed by r219708.

hfinkel avatar Oct 14 '14 21:10 hfinkel