On Wed, Dec 18, 2019 at 10:59 AM Andrew Pinski <pins...@gmail.com> wrote: > > On Wed, Dec 18, 2019 at 1:18 AM Hongtao Liu <crazy...@gmail.com> wrote: > > > > On Wed, Dec 18, 2019 at 4:26 PM Segher Boessenkool > > <seg...@kernel.crashing.org> wrote: > > > > > > On Wed, Dec 18, 2019 at 10:37:11AM +0800, Hongtao Liu wrote: > > > > Hi: > > > > This patch is to simplify A * C + (-D) -> (A - D/C) * C when C is a > > > > power of 2 and D mod C == 0.
Looks like a subset of what fold_plusminus_mult_expr does? > > > > bootstrap and make check is ok. > > > > > > Why would this be a good idea? It is not reducing the number of > > > operators or similar? > > > > > It helps VN, so that fre will delete redundant load. So it's basically a canonicalization. What you have to watch for is code doing the reverse (extract_muldiv and the associate: cases in fold-const.c are a bad example here). > It is basically doing a factoring and undoing an optimization that was > done in the front-end (see pointer_int_sum in c-common.c). > But I think the optimization in the front-end should be removed. It > dates from 1992, a time when GCC did not anything on the tree level > and there was no GCSE (PRE) and the CSE was limited. Agreed (as this is a premature point). But not at this point - I think I tried this and there's quite some fallout. Also always watch for unefined overflow issues. Richard. > Thanks, > Andrew Pinski > > > > > > > > Segher > > > > > > > > -- > > BR, > > Hongtao