On Thu, Aug 10, 2017 at 4:09 PM, Jackson Woodruff <jackson.woodr...@foss.arm.com> wrote: > Hi all, > > The patch implements the division opitmizations discussed in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 . > > The implemented change differs slightly from the > proposed one in that we re-associate: > > C / x comparison 0.0 -> x comparison' 0.0 > > Where C is any constant and comparison' is changed as > appropriate if C is negative. > > The implementations also removes the division from: > > x / C comparison 0.0 -> x comparison' 0.0 > > Where again, comparison' is changed as appropriate if C is > negative. > > We also change the association of > > x / (y * C) -> (x / C) / y > > If C is a constant.
Why's that profitable? > All of the above require > -funsafe-math-optimizations. > > We also change: > > x / (- y) -> (-x) / y Why? (it's only one of the possible canonicalizations) Note there are exactly two RDIV_EXPR simplifications remaining in fold_binary_loc, maybe you can move them to match.pd (beware of negate_expr_p ... this negate optimization should eventually move to backprop). > Which requires -fno-trapping-math. > > Bootstrapped and regtested (with part 2 of this patch) on aarch64. > > OK for trunk? > > (Apologies if the recipients in the 'to' field received this twice, > I accidentally sent this from an email gcc-patches doesn't accept) > > Jackson > > gcc/ > > 2017-08-03 Jackson Woodruff <jackson.woodr...@arm.com> > > PR 71026/tree-optimization > * match.pd: New patterns. > > > gcc/testsuite > > 2017-08-03 Jackson Woodruff <jackson.woodr...@arm.com> > > PR 71026/tree-optimization > * gcc.dg/associate_comparison_1.c: New. > * gcc.dg/associate_division_2.c: New. >