On Wed, Aug 06, 2014 at 10:22:19AM +0200, Marek Polacek wrote: > On Tue, Aug 05, 2014 at 02:14:21PM -0600, Jeff Law wrote: > > My concern is the code we're removing discusses the need to simplify when > > these expressions are in static initializers. What's going to ensure that > > we're still simplifying instances which appear in static initializers? I > > don't see anything which tests that. And does it still work for targets > > which utilize PSImode? > > Aw nuts. So with the patch we'd start erroring out on > static __PTRDIFF_TYPE__ d1 = p - (p + 1); > static __PTRDIFF_TYPE__ d2 = p - (p - 1); > (it's nowhere in the testsuite/code base - and I hadn't noticed that > until today :() > while we'd still accept > static __PTRDIFF_TYPE__ d5 = (p - 1) - p; > static __PTRDIFF_TYPE__ d6 = (p + 1) - p; > (Those are not constant expression according to ISO C.) > > The reason is that fold_build can fold > "(long int) (p + 4) - (long int) p" to 4, but not > "(long int) p - (long int) (p + 4)". > > That means we have to have a way how to fold the latter, but only in > static initializers. So I guess I need to implement this in > fold-const.c... Oh well. > > Nevertheless, I'd guess the fwprop bits could go in separately (it's > beneficial for C++).
Well, if you are going to implement it in fwprop AND fold-const, then the natural place to fix that would be in *.pd on the match-and-simplify branch. Jakub