public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/hard12)] Optimize nonstandard boolean validity checking Date: Fri, 6 May 2022 08:37:23 +0000 (GMT) [thread overview] Message-ID: <20220506083723.CE80B3856DF0@sourceware.org> (raw) https://gcc.gnu.org/g:4b43b3adb9ad760f4266ade92bf2d8d64cc520a9 commit 4b43b3adb9ad760f4266ade92bf2d8d64cc520a9 Author: Alexandre Oliva <oliva@adacore.com> Date: Fri May 6 05:34:15 2022 -0300 Optimize nonstandard boolean validity checking Validity checking of enumerations with nonstandard representation starts by checking the value range, then calling _rep_to_pos to verify that the value itself is valid. The value range check is thus redundant and inefficient: the _rep_to_pos call is normally inlined when optimizing for speed and the range check slows down the fast path; it is unnecesary and undesirable when optimizing for size, and just unnecessary when not optimizing. This patch thus drops the range check for nonstandard boolean types. [changelog] * exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Valid>: Drop redundant range check for nonstandard booleans. Diff: --- gcc/ada/exp_attr.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 5374dd4d7e9..c31d7e06d45 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -7254,7 +7254,11 @@ package body Exp_Attr is New_Occurrence_Of (Standard_False, Loc))), Right_Opnd => Make_Integer_Literal (Loc, 0)); - if Ptyp /= PBtyp + -- Skip the range test for boolean types, as it buys us + -- nothing. The function called above already fails for + -- values different from both True and False. + + if Ptyp /= PBtyp and then not Is_Boolean_Type (PBtyp) and then (Type_Low_Bound (Ptyp) /= Type_Low_Bound (PBtyp) or else
reply other threads:[~2022-05-06 8:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220506083723.CE80B3856DF0@sourceware.org \ --to=aoliva@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).