[PATCH] D34579: Fold fneg and fabs like multiplications

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 16:44:30 PDT 2017


rampitec planned changes to this revision.
rampitec added a comment.

In https://reviews.llvm.org/D34579#789534, @apinski-cavium wrote:

> > (fmul X, (select (fcmp X > 0.0), -1.0, 1.0)) -> (fneg X)
>
> Is not correct.
>
> It should be:
>  (fmul X, (select (fcmp X > 0.0), -1.0, 1.0)) -> (fneg (fabs X))
>
> If X was -2.0, (fmul X, (select (fcmp X > 0.0), -1.0, 1.0)) is (fmul -2.0, (select false, -1.0, 1.0) ) =>(fmul -2.0, 1.0 ) => -2.0.  Which is different from (fneg -2.0) => 2.0.


Ugh... right.


https://reviews.llvm.org/D34579





More information about the llvm-commits mailing list