Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-16 Thread Marc Glisse
On Tue, 16 Jun 2020, Feng Xue OS wrote: Here is an question about pointer operation: Pointer is treated as unsigned in comparison operation, while distance between pointers is signed. Then we can not assume the below conclusion is true? (ptr_a > ptr_b) => (ptr_a - ptr_b) >= 0 Yes yo

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-15 Thread Feng Xue OS via Gcc-patches
nks, Feng From: Marc Glisse Sent: Wednesday, June 3, 2020 10:32 PM To: Feng Xue OS Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234) On Wed, 3 Jun 2020, Feng Xue OS via Gcc-patches wrote: >> Ah, looking at the

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-15 Thread Richard Biener via Gcc-patches
har *a, size_t n) > +{ > + char *b1 = a + 8 * n; > + char *b2 = a + 8 * (n - 1); > + > + return b1 - b2; > +} > + > +ptrdiff_t goo (char *a, size_t n, size_t m) > +{ > + char *b1 = a + 8 * n; > + char *b2 = a + 8 * (n + 1); > + > + return (b1 + m) - (b2 + m); > +} > +

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-05 Thread Feng Xue OS via Gcc-patches
= a + 8 * (n + 1); + + return (b1 + m) - (b2 + m); +} + +/* { dg-final { scan-tree-dump-times "return 8;" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "return -8;" 1 "forwprop1" } } */ -- ________________ From: Richard Bi

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-04 Thread Richard Biener via Gcc-patches
On Wed, Jun 3, 2020 at 4:33 PM Marc Glisse wrote: > > On Wed, 3 Jun 2020, Feng Xue OS via Gcc-patches wrote: > > >> Ah, looking at the PR, you decided to perform the operation as unsigned > >> because that has fewer NOP conversions, which, in that particular testcase > >> where the offsets are ori

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-03 Thread Marc Glisse
On Wed, 3 Jun 2020, Feng Xue OS via Gcc-patches wrote: Ah, looking at the PR, you decided to perform the operation as unsigned because that has fewer NOP conversions, which, in that particular testcase where the offsets are originally unsigned, means we simplify better. But I would expect it to

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-03 Thread Feng Xue OS via Gcc-patches
>> * match.pd ((PTR + A) - (PTR + B)) -> (ptrdiff_t)(A - B): New >> simplification. > Not new, modified. OK. >> * ((PTR_A + O) - (PTR_B + O)) -> (PTR_A - PTR_B): New simplification. > O might not be the best choice because of how close it looks to 0. OK. > What don't you like

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-03 Thread Feng Xue OS via Gcc-patches
>> This patch is meant to add match rules to simplify patterns as: >> >> o. (pointer + offset_a) - (pointer + offset_b) -> (ptrdiff_t) (offset_a >> - offset_b) >> o. (pointer_a + offset) - (pointer_b + offset) -> (pointer_a - pointer_b) > You are also changing the existing pattern which I

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-02 Thread Marc Glisse
On Mon, 1 Jun 2020, Feng Xue OS via Gcc-patches wrote: * match.pd ((PTR + A) - (PTR + B)) -> (ptrdiff_t)(A - B): New simplification. Not new, modified. * ((PTR_A + O) - (PTR_B + O)) -> (PTR_A - PTR_B): New simplification. O might not be the best choice because of ho

Re: [PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-02 Thread Richard Biener via Gcc-patches
On Mon, Jun 1, 2020 at 10:37 AM Feng Xue OS via Gcc-patches wrote: > > This patch is meant to add match rules to simplify patterns as: > > o. (pointer + offset_a) - (pointer + offset_b) -> (ptrdiff_t) (offset_a - > offset_b) > o. (pointer_a + offset) - (pointer_b + offset) -> (pointer_a -

[PATCH] Add pattern for pointer-diff on addresses with same base/offset (PR 94234)

2020-06-01 Thread Feng Xue OS via Gcc-patches
This patch is meant to add match rules to simplify patterns as: o. (pointer + offset_a) - (pointer + offset_b) -> (ptrdiff_t) (offset_a - offset_b) o. (pointer_a + offset) - (pointer_b + offset) -> (pointer_a - pointer_b) Bootstrapped/regtested on x86_64-linux and aarch64-linux. Feng --