public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Qing Zhao <qing.zhao@oracle.com>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: HELP: Questions on unshare_expr
Date: Fri, 12 Jan 2024 17:28:20 +0100	[thread overview]
Message-ID: <70C34042-B741-4697-9524-396CB9D40DF8@gmail.com> (raw)
In-Reply-To: <50C8811D-9C2A-4FFB-9FC5-D24C5A76F868@oracle.com>



> Am 12.01.2024 um 16:55 schrieb Qing Zhao <qing.zhao@oracle.com>:
> 
> Hi,
> 
> I have some questions on using the utility routine “unshare_expr”:
> 
> From my understanding, there should be NO shared nodes in a GENERIC function.
> Otherwise, gimplication might fail.

There is sharing and this is why we unshare everything before gimplification.

> Therefore, when we insert new tree nodes manually into the GENERIC function, we should
> Make sure there is no shared nodes introduced.
> 
> 1. Is the above understanding correct?

No

> 2. Is there any tool to check there is no shared nodes in the GENERIC function?
> 3. Are there any tree nodes that are allowed to be shared in a GENERIC function? If so, what are they?

There’s some allowed sharing on GIMPLE and a verifier.

> 4. For the following:
> 
> If both “op1” and “op2” are existing tree nodes in the current GENERIC function,
> and we will insert a new tree node:
> 
> tree  new_tree = build2 (CODE, TYPE, op1, op2)
> 
> 
> Should we add “unshare_expr” on both “op1” and “op2” as:
> 
> Tree new_tree = build2 (CODE, TYPE, unshare_expr (op1), unshare_expr (op2))
> ?

Not necessarily but instead you have to watch for evaluating side-effects only once.  See save_expr.

> 
> If op2 is a node that is allowed to be shared, whether the additional “unshare_expr” on it trigger any potential problem?

If you unshare side-effects that’s generating wrong-code.  Otherwise unsharing is safe.

Richard 

> Thanks a lot for your help.
> 
> Qing
> 
> 
> 
> 
> 

  reply	other threads:[~2024-01-12 16:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 15:54 Qing Zhao
2024-01-12 16:28 ` Richard Biener [this message]
2024-01-12 17:30   ` Qing Zhao
2024-01-15  8:13     ` Eric Botcazou
2024-01-15 16:42       ` Qing Zhao
2024-01-15  9:31     ` Richard Biener
2024-01-15 14:54       ` Qing Zhao
2024-01-15 15:06         ` Jakub Jelinek
2024-01-15 16:41           ` Qing Zhao
2024-01-16 20:25       ` Qing Zhao
2024-01-17  6:42         ` Richard Biener
2024-01-17  6:43           ` Richard Biener
2024-01-18 14:45             ` Qing Zhao
2024-01-19  9:30               ` Richard Biener
2024-01-19 16:25                 ` Qing Zhao
2024-01-22  7:40                   ` Richard Biener
2024-01-22 14:52                     ` Qing Zhao
2024-01-22 16:54                       ` Qing Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70C34042-B741-4697-9524-396CB9D40DF8@gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=qing.zhao@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).