[PATCH] D32596: [DAGCombine] Transform (fadd A, (fmul B, -2.0)) -> (fsub A, (fadd B, B)).
Chad Rosier via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 12:49:19 PDT 2017
mcrosier added a comment.
In https://reviews.llvm.org/D32596#746314, @spatel wrote:
> In https://reviews.llvm.org/D32596#746288, @mcrosier wrote:
>
> > While InstCombine does nothing, the reassociation pass will canonicalize to
> >
> > (fsub A, (fmul/fdiv B, -C)) -> (fadd A, (fmul/fdiv B, C))
> > (fadd A, (fmul/fdiv B, -C)) -> (fsub A, (fmul/fdiv B, C))
>
>
> Thanks for checking those out. I haven't looked at the reassociation pass very much. I'm surprised to see it flip a constant's sign and create an fsub rather than fadd. Any ideas why that is a good thing to do?
AFAICT reassociation is trying to force all constants to be positive so it can increase the opportunities for factorization. This should also allows CSE and GVN to eliminate more duplicate expressions (per https://reviews.llvm.org/D4904 and https://reviews.llvm.org/D5363).
Repository:
rL LLVM
https://reviews.llvm.org/D32596
More information about the llvm-commits
mailing list