[PATCH] Allow FMAs in safe math mode in some cases when one operand of the fmul is either exactly 0.0 or exactly 1.0.

Stephen Lin swlin at post.harvard.edu
Tue Jul 9 16:20:26 PDT 2013


>> I'll add more
>> checks for the scalar case and update this one first.
>>
>
> Great!

Well, allowing undef causes as test failure that I'm not sure is
meaningful at first glance (it's a reduced bug case test rather than a
focused test of specific construct.)

In any case, I know that technically we could do anything we want with
undef, but I'd rather be more developer-friendly and not go that
direction without thinking about it more carefully because it may
actually break programs if introducing the FMA changes results.
(Losing the rounding step won't change a whole lot usually, but it
could make a sum that guaranteed to be 0 become non-zero, or something
like that, and a fmul with an undefined operand is probably a lot more
common in user code than one would like.)

Other than that, I updated the patch with more cases and took off the
restriction that zero had to be positive (since I realized it doesn't
matter--the only difference between FMA and mul + add is the rounding
step, I think, and that's not affected.)

Since there's a lot of new code paths through this function, I will
add more test coverage to make sure we don't have any false positives
and to help prevent regression in the future; in the meantime please
(Hal or anyone else) review the new source changes, if you get a
chance.

Thanks,
Stephen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fma-through-zero-or-one-v2.patch
Type: application/octet-stream
Size: 14126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130709/de596d0b/attachment.obj>


More information about the llvm-commits mailing list