public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Richard Biener <rguenther@suse.de>
Cc: Jakub Jelinek <jakub@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	Michael Matz <matz@suse.de>
Subject: Re: [PATCH][4/5] Handle internal_fn in operand_equal_p
Date: Sun, 22 Feb 2015 13:13:00 -0000	[thread overview]
Message-ID: <54E9CFF3.6070908@mentor.com> (raw)
In-Reply-To: <alpine.LSU.2.11.1502201253500.28824@zhemvz.fhfr.qr>

[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]

On 20-02-15 12:54, Richard Biener wrote:
> On Thu, 19 Feb 2015, Tom de Vries wrote:
>
>> On 19-02-15 14:07, Richard Biener wrote:
>>> On Thu, 19 Feb 2015, Jakub Jelinek wrote:
>>>
>>>> On Thu, Feb 19, 2015 at 01:44:46PM +0100, Richard Biener wrote:
>>>>> I'd call it a bug though, and we do have internal fns in
>>>>> generic already thus the issue is latent (with ubsan at least).
>>>>>
>>>>> Which means ok for trunk now.
>>>>
>>>> But the patch should better handle the internal calls right.
>>>> I.e. return 0 only if only one, not both CALL_EXPR_FNs are NULL,
>>>> or if both are NULL and CALL_EXPR_IFN is different, or if
>>>> call_expr_nargs is different.
>>>
>>> The question is whether generic call handling works (esp. call_expr_flags
>>> works correctly - the argument compare should work fine already).
>>>
>>> Tom - care to update the patch?
>>>
>>
>> I agree, the current patch is conservative and we can do betterns,
-
.
>> But I think it's wiser to do that as a stage1 follow-up, and commit this
>> conservative patch for stage4. Is that acceptable?
>
> Then just defer it for stage1 completely.  If a problem pops up with
> GCC 5 we can backport the proper patch together with a testcase.
>

Updated patch according to Jakub's comments, retested.

OK for stage1?

Thanks,
- Tom

[-- Attachment #2: 0004-Handle-internal_fn-in-operand_equal_p.patch --]
[-- Type: text/x-patch, Size: 1836 bytes --]

2015-02-17  Tom de Vries  <tom@codesourcery.com>

	* fold-const.c (operand_equal_p): Handle INTERNAL_FNs.
	* calls.c (call_expr_flags): Same.
---
 gcc/calls.c      |  2 ++
 gcc/fold-const.c | 23 +++++++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/calls.c b/gcc/calls.c
index ec44624..2919464 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -847,6 +847,8 @@ call_expr_flags (const_tree t)
 
   if (decl)
     flags = flags_from_decl_or_type (decl);
+  else if (CALL_EXPR_FN (t) == NULL_TREE)
+    flags = internal_fn_flags (CALL_EXPR_IFN (t));
   else
     {
       t = TREE_TYPE (CALL_EXPR_FN (t));
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8377120..3013adb 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3032,11 +3032,26 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
       switch (TREE_CODE (arg0))
 	{
 	case CALL_EXPR:
-	  /* If the CALL_EXPRs call different functions, then they
-	     clearly can not be equal.  */
-	  if (! operand_equal_p (CALL_EXPR_FN (arg0), CALL_EXPR_FN (arg1),
-				 flags))
+	  if ((CALL_EXPR_FN (arg0) == NULL_TREE)
+	      != (CALL_EXPR_FN (arg1) == NULL_TREE))
+	    /* If not both CALL_EXPRs are either internal or normal function
+	       functions, then they are not equal.  */
 	    return 0;
+	  else if (CALL_EXPR_FN (arg0) == NULL_TREE)
+	    {
+	      /* If the CALL_EXPRs call different internal functions, then they
+		 are not equal.  */
+	      if (CALL_EXPR_IFN (arg0) != CALL_EXPR_IFN (arg1))
+		return 0;
+	    }
+	  else
+	    {
+	      /* If the CALL_EXPRs call different functions, then they are not
+		 equal.  */
+	      if (! operand_equal_p (CALL_EXPR_FN (arg0), CALL_EXPR_FN (arg1),
+				     flags))
+		return 0;
+	    }
 
 	  {
 	    unsigned int cef = call_expr_flags (arg0);
-- 
1.9.1


  reply	other threads:[~2015-02-22 12:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19 10:48 [stage1] Postpone expanding va_arg until pass_stdarg Tom de Vries
2015-02-19 10:51 ` [PATCH][1/5] Disable lang_hooks.gimplify_expr in free_lang_data Tom de Vries
2015-02-19 12:41   ` Richard Biener
2015-02-19 10:59 ` [PATCH][2/5] Add gimple_find_sub_bbs Tom de Vries
2015-02-19 12:41   ` Richard Biener
2015-02-19 12:51     ` Jakub Jelinek
2015-02-19 13:03       ` Marek Polacek
2015-02-19 13:31         ` Richard Biener
2015-02-19 13:07       ` Richard Biener
2015-02-22 12:47     ` Tom de Vries
2015-02-19 11:06 ` [PATCH][3/5] Factor optimize_va_list_gpr_fpr_size out of pass_stdarg::execute Tom de Vries
2015-02-19 12:44   ` Richard Biener
2015-02-19 11:37 ` [PATCH][4/5] Handle internal_fn in operand_equal_p Tom de Vries
2015-02-19 12:49   ` Richard Biener
2015-02-19 12:59     ` Jakub Jelinek
2015-02-19 13:09       ` Richard Biener
2015-02-19 15:31         ` Tom de Vries
2015-02-20 11:59           ` Richard Biener
2015-02-22 13:13             ` Tom de Vries [this message]
2015-02-23 10:19               ` Richard Biener
2015-02-24 13:09                 ` Fwd: " Tom de Vries
2015-02-19 12:08 ` [PATCH][5/5] Postpone expanding va_arg until pass_stdarg Tom de Vries
2015-02-19 13:05   ` Richard Biener
2015-02-22 13:24     ` Tom de Vries
2015-02-23  9:03       ` Michael Matz
2015-02-23 10:36         ` Tom de Vries
2015-02-24  8:26           ` Tom de Vries
2015-03-10 15:31             ` [PING] [PATCH][5b/5] Avoid running expand_ifn_va_arg_1 in functions without va_arg Tom de Vries
2015-04-16  8:50               ` [PING^2] " Tom de Vries
2015-04-16  8:56                 ` Richard Biener
2015-03-10 15:31       ` [PING] [PATCH][5a/5] Postpone expanding va_arg until pass_stdarg Tom de Vries
2015-04-16  8:50         ` [PING^2] " Tom de Vries
2015-04-16  8:55           ` Richard Biener
2015-04-21  5:32             ` Bin.Cheng
2015-06-09 11:04             ` Alan Lawrence
2015-06-09 11:07               ` Richard Biener
2015-06-09 13:03                 ` Tom de Vries
2015-06-09 13:07                   ` Richard Biener
2015-06-09 13:30                   ` Alan Lawrence

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=54E9CFF3.6070908@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=matz@suse.de \
    --cc=rguenther@suse.de \
    /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).