public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Janne Blomqvist <blomqvist.janne@gmail.com>
Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, fortran, PR 82869] Introduce default_logical_type_node and logical_type_node
Date: Tue, 07 Nov 2017 20:06:00 -0000	[thread overview]
Message-ID: <20171107200641.GA47000@troutmask.apl.washington.edu> (raw)
In-Reply-To: <1510079175-10927-1-git-send-email-blomqvist.janne@gmail.com>

On Tue, Nov 07, 2017 at 08:26:15PM +0200, Janne Blomqvist wrote:
> Earlier GFortran used to redefine boolean_type_node, which in the rest
> of the compiler means the C/C++ _Bool/bool type, to the Fortran
> default logical type.  When this redefinition was removed, a few
> issues surfaced. Namely,
> 
> 1) PR 82869, where we created a boolean tmp variable, and passed it to
> the runtime library as a Fortran logical variable of a different size.
> 
> 2) Fortran specifies that logical operations should be done with the
> default logical kind, not in any other kind.
> 
> 3) Using 8-bit variables have some issues, such as
>    - on x86, partial register stalls and length prefix changes.
>    - s390 has a compare with immediate and jump instruction which
>      works with 32-bit but not 8-bit quantities.
> 
> This patch addresses (2) by introducing a type
> default_logical_type_node which is used when evaluating Fortran
> logical expressions. (3) is addressed by introducing
> logical_type_node, a tree representing a logical(kind=4) type which
> can be used for compiler-generated temporary
> variables. logical_type_node is always 4 bytes. As a side effect, (1)
> is also fixed, though there might be some latent bug lurking there
> still.
> 
> For x86-64, using the Polyhedron benchmark suite, no performance or
> code size difference worth mentioning was observed.
> 
> Regtested on x86_64-pc-linux-gnu. Ok for trunk?

I scanned the patch and it looks ok to me (most a
mechanical find/replace operation).  One thing those,

> diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
> index 78477a9..602d369 100644
> --- a/gcc/fortran/trans-types.c
> +++ b/gcc/fortran/trans-types.c
> @@ -62,6 +62,12 @@ tree ppvoid_type_node;
>  tree pchar_type_node;
>  tree pfunc_type_node;
>  
> +tree default_logical_type_node;
> +tree default_logical_true_node;
> +tree default_logical_false_node;
> +tree logical_type_node;
> +tree logical_true_node;
> +tree logical_false_node;
>  tree gfc_charlen_type_node;
>  
>  tree gfc_float128_type_node = NULL_TREE;
> @@ -1003,6 +1009,15 @@ gfc_init_types (void)
>  			wi::mask (n, UNSIGNED,
>  				  TYPE_PRECISION (size_type_node)));
>  
> +
> +  default_logical_type_node = gfc_get_logical_type (gfc_default_logical_kind);
> +  default_logical_true_node = build_int_cst (default_logical_type_node, 1);
> +  default_logical_false_node = build_int_cst (default_logical_type_node, 0);
> +
> +  logical_type_node = gfc_get_logical_type (4);

Can you add a comment to note that the 4 is purposely chosen?
A year or so from now, someone might change this to gfc_default_logical_kind
without understand/recalling why 4 is used.

-- 
steve

  reply	other threads:[~2017-11-07 20:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 18:26 Janne Blomqvist
2017-11-07 20:06 ` Steve Kargl [this message]
2017-11-07 20:38   ` Janne Blomqvist
2017-11-07 22:27     ` Steve Kargl
2017-11-08 11:57       ` Janne Blomqvist
2017-11-13 20:04         ` Janne Blomqvist

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=20171107200641.GA47000@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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).