[PATCH] D26602: [DAGCombiner] do not fold (fmul (fadd X, 1), Y) -> (fmad X, Y, Y) by default
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 08:33:31 PST 2016
nhaehnle added a comment.
In https://reviews.llvm.org/D26602#606673, @spatel wrote:
> 3. There's an unanswered question of whether we can do this with FPOpFusion::Fast with TargetOptions::NoInfsFPMath. That depends on whether x * y + x is always more precise than the original x * (y + 1).
Here's an example with binary floating point numbers with two bits of mantissa.
x = 1.01
y = 111
x * (y + 1) = 1.01 * 1000 = 1010 (this is the exact result; no rounding occurs at any step)
x * y + x = 1000.11 + 1.01 =r 1000 + 1.01 = 1001.01 =r 1000 (with rounding towards zero)
The example relies on rounding towards zero at least in the second step, but it does seem to disqualify the transform at least for FMAD (i.e. with an intermediate rounding step). I suspect FMA (without intermediate rounding) is fine, but I have no proof.
https://reviews.llvm.org/D26602
More information about the llvm-commits
mailing list