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
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
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);
> +}
> +
= 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
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
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
>> * 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
>> 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
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
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 -
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
--
11 matches
Mail list logo