On Sat, Oct 24, 2015 at 5:14 AM, Jason Merrill <ja...@redhat.com> wrote: > On 10/21/2015 12:16 AM, Richard Biener wrote: >> >> On Tue, Oct 20, 2015 at 9:10 PM, Jason Merrill <ja...@redhat.com> wrote: >>> >>> I made this change on the delayed folding branch and then noticed that it >>> broke pointer-arith-10.c, which you added to the testsuite. The patch >>> changes the -original dump from >>> >>> return (char *) ((sizetype) p + (sizetype) i); >>> >>> to >>> >>> return (char *) i + (sizetype) p; >>> >>> It's not clear to me why the former should be preferred. Any thoughts? >> >> >> We probably regressed for the former and the dump-scanning just didn't >> notice. We wanted to check for >> >> return p + (sizetype) i; >> >> at least GCC 4.4.7 produces that and 4.5.2 regressed. >> >> Some time ago we had a folding that explicitely swapped pointer-ness >> of an integer op like the testcase was supposed to test. But I remember >> I removed this because it's incorrect (pointer arithmetic is more >> constrained >> than unsigned integer arithmetic): >> >> 2009-01-16 Richard Guenther <rguent...@suse.de> >> >> PR tree-optimization/38835 >> PR middle-end/36227 >> * fold-const.c (fold_binary): Remove PTR + INT -> (INT)(PTR p+ >> INT) >> and INT + PTR -> (INT)(PTR p+ INT) folding. >> * tree-ssa-address.c (create_mem_ref): Properly use >> POINTER_PLUS_EXPR. >> >> so I think the testcase should be simply removed. > > > How about this change to the testcase?
Hmm, I'd say we want to test for the correctness issue as well, thus pleas also add /* { dg-final { scan-tree-dump-not "return p +" "original" } } */ as we do not want 'p + (sizetype)i' as that is incorrect. Thanks, Richard. > Jason > >