public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/99517] __builtin_convertvector with casts
Date: Thu, 11 Mar 2021 08:09:09 +0000	[thread overview]
Message-ID: <bug-99517-4-O3EZsL9mfd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99517-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99517

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> --- gcc/ipa-icf-gimple.c.jj	2021-01-04 10:25:38.752234741 +0100
> +++ gcc/ipa-icf-gimple.c	2021-03-10 15:02:06.287502784 +0100
> @@ -667,7 +667,7 @@ func_checker::compare_gimple_call (gcall
>    tree fntype1 = gimple_call_fntype (s1);
>    tree fntype2 = gimple_call_fntype (s2);
>  
> -  /* For direct calls we verify that types are comopatible so if we matced
> +  /* For direct calls we verify that types are compatible so if we matched
>       callees, callers must match, too.  For indirect calls however verify
>       function type.  */
>    if (!gimple_call_fndecl (s1))
> @@ -703,6 +703,14 @@ func_checker::compare_gimple_call (gcall
>    t1 = gimple_get_lhs (s1);
>    t2 = gimple_get_lhs (s2);
>  
> +  /* For internal calls, lhs types need to be verified, as neither fntype
> nor
> +     callee comparisions can catch that.  */
> +  if (gimple_call_internal_p (s1)
> +      && t1
> +      && t2
> +      && !compatible_types_p (TREE_TYPE (t1), TREE_TYPE (t2)))
> +    return return_false_with_msg ("GIMPLE internal call LHS type mismatch");
> +
>    return compare_operand (t1, t2, get_operand_access_type (&map, t1));
>  }
>  
> 
> fixes this for me, working on the testcase for testsuite now.
> 
> Anyway, I'm a little bit worried that gimple_call_fntype isn't compared for
> direct calls, gimple_call_fntype doesn't have to match the function type of
> gimple_call_fndecl.

The comment says that we match that the fndecls definitions are equal,
one could argue that it's undefined behavior if the same definition is
invoked via two different gimple_call_fntype signatures and thus it's
OK to just go ahead (I think actual arguments are also compared so it
would collide there, too).

> And also surprised that compare_ssa_name e.g. doesn't compare
> SSA_NAME_OCCURS_IN_ABNORMAL_PHI or SSA_NAME_PTR_INFO or SSA_NAME_RANGE_INFO.
> Maybe for the latter two we are fine if we only optimize away
> __builtin_unreachable calls after IPA, but if we do it before, e.g. some
> function could have if (cond) __builtin_unreachable (); assertions that EVRP
> would stick into SSA_NAME_RANGE_INFO and another function be the same except
> without those assertions.  If ICF merges the latter into the former and
> calls the latter with arguments violating the assertions of the former, it
> might be miscompiled.

Hmm, yeah.  I guess one could try to carefully craft such a testcase.
For example non-null ranges can also be created from dead loads like

foo (int *p)
{
  *p;
  if (p != 0)
...

when you make sure to not run DCE before EVRP.  Not sure if that's enough
of a building-block to create a testcase.

  parent reply	other threads:[~2021-03-11  8:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 13:27 [Bug c/99517] New: " me+gcc.gnu at lelf dot lu
2021-03-10 13:53 ` [Bug c/99517] " rguenth at gcc dot gnu.org
2021-03-10 14:02 ` [Bug ipa/99517] " jakub at gcc dot gnu.org
2021-03-10 14:09 ` marxin at gcc dot gnu.org
2021-03-10 14:14 ` jakub at gcc dot gnu.org
2021-03-10 14:57 ` jakub at gcc dot gnu.org
2021-03-11  8:09 ` rguenth at gcc dot gnu.org [this message]
2021-03-11 10:18 ` cvs-commit at gcc dot gnu.org
2021-03-11 10:30 ` [Bug ipa/99517] [10 Regression] " jakub at gcc dot gnu.org
2021-03-19 23:30 ` cvs-commit at gcc dot gnu.org
2021-03-20  8:09 ` jakub at gcc dot gnu.org

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=bug-99517-4-O3EZsL9mfd@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).