public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, jit@gcc.gnu.org
Subject: Re: [committed] Implement LANG_HOOKS_TYPE_FOR_SIZE for jit
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <CAFiYyc0aumhZKG=L2FY+nXrGip2gUt60AN-F8+EDEQTmYme85A@mail.gmail.com> (raw)
In-Reply-To: <1484775940-11692-1-git-send-email-dmalcolm@redhat.com>

On Wed, Jan 18, 2017 at 10:45 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> The jit testcase test-nested-loops.c was crashing.
>
> Root cause is that deep inside loop optimization we're now exposing
> this call within fold-const.c which wasn't being hit before:
>
> 4082      /* Compute the mask to access the bitfield.  */
> 4083      unsigned_type = lang_hooks.types.type_for_size (*pbitsize, 1);
>
> and the jit's implementation of LANG_HOOKS_TYPE_FOR_SIZE was a
> placeholder that asserted it wasn't called.
>
> This patch implements a proper LANG_HOOKS_TYPE_FOR_SIZE for jit,
> by taking LTO's implementation.
>
> Fixes test-nested-loops.c, along with the related failures in
> test-combination.c and test-threads.c due to reusing the test.
>
> This fixes all known failures in jit.sum, putting it at 8609 passes.
>
> Committed to trunk as r244600.

I suppose we could instead make the lto hook the default (thus move it
to langhooks.c as lhd_type_for_size).  Note similar issues may arise
from type_for_mode?  Ah, I see you have that one...

Richard.

> gcc/jit/ChangeLog:
>         * dummy-frontend.c (jit_langhook_type_for_size): Implement, using
>         lto's lto_type_for_size.
> ---
>  gcc/jit/dummy-frontend.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c
> index 8f28e7f..5955854 100644
> --- a/gcc/jit/dummy-frontend.c
> +++ b/gcc/jit/dummy-frontend.c
> @@ -207,12 +207,53 @@ jit_langhook_type_for_mode (enum machine_mode mode, int unsignedp)
>    return NULL;
>  }
>
> +/* Return an integer type with PRECISION bits of precision,
> +   that is unsigned if UNSIGNEDP is nonzero, otherwise signed.  */
> +
>  static tree
> -jit_langhook_type_for_size (unsigned int bits ATTRIBUTE_UNUSED,
> -                           int unsignedp ATTRIBUTE_UNUSED)
> +jit_langhook_type_for_size (unsigned precision, int unsignedp)
>  {
> -  gcc_unreachable ();
> -  return NULL;
> +  int i;
> +
> +  if (precision == TYPE_PRECISION (integer_type_node))
> +    return unsignedp ? unsigned_type_node : integer_type_node;
> +
> +  if (precision == TYPE_PRECISION (signed_char_type_node))
> +    return unsignedp ? unsigned_char_type_node : signed_char_type_node;
> +
> +  if (precision == TYPE_PRECISION (short_integer_type_node))
> +    return unsignedp ? short_unsigned_type_node : short_integer_type_node;
> +
> +  if (precision == TYPE_PRECISION (long_integer_type_node))
> +    return unsignedp ? long_unsigned_type_node : long_integer_type_node;
> +
> +  if (precision == TYPE_PRECISION (long_long_integer_type_node))
> +    return unsignedp
> +          ? long_long_unsigned_type_node
> +          : long_long_integer_type_node;
> +
> +  for (i = 0; i < NUM_INT_N_ENTS; i ++)
> +    if (int_n_enabled_p[i]
> +       && precision == int_n_data[i].bitsize)
> +      return (unsignedp ? int_n_trees[i].unsigned_type
> +             : int_n_trees[i].signed_type);
> +
> +  if (precision <= TYPE_PRECISION (intQI_type_node))
> +    return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
> +
> +  if (precision <= TYPE_PRECISION (intHI_type_node))
> +    return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
> +
> +  if (precision <= TYPE_PRECISION (intSI_type_node))
> +    return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
> +
> +  if (precision <= TYPE_PRECISION (intDI_type_node))
> +    return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
> +
> +  if (precision <= TYPE_PRECISION (intTI_type_node))
> +    return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
> +
> +  return NULL_TREE;
>  }
>
>  /* Record a builtin function.  We just ignore builtin functions.  */
> --
> 1.8.5.3
>

  reply	other threads:[~2017-01-19  9:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 David Malcolm
2017-01-01  0:00 ` Richard Biener [this message]
2017-01-01  0:00   ` [PATCH] Make LTO's implementation of LANG_HOOKS_TYPE_FOR_SIZE the default David Malcolm
2017-01-01  0:00     ` Richard Biener

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='CAFiYyc0aumhZKG=L2FY+nXrGip2gUt60AN-F8+EDEQTmYme85A@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@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).