[PATCH] D39830: [DAGCombine] Transform (A + -2.0*B*C) -> (A - (B+B)*C)
Chad Rosier via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 11:10:07 PST 2017
mcrosier added a comment.
In https://reviews.llvm.org/D39830#921949, @craig.topper wrote:
> This solution doesn't seem very general, it won't catch.
>
> double test2(double a, double b, double c, double d) {
> return a + -2.0*b*c*d;
> }
>
>
> The constant can be many layers of multiplies away. Reassociate pushes constants down the tree. Should reassociate be pulling out the negate when it factors the tree?
Reassociation prefer to "break up subtracts" by converting X-Y to X+-Y, so it can better commute operands to expose more opportunities to reassociate. It turns out that instcombine also prefers this form when Y is a constant. I'm not sure pulling out the negate wouldn't work unless we decide to change the canonical form throughout the pipeline, right?
https://reviews.llvm.org/D39830
More information about the llvm-commits
mailing list