public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1726] fold-const: Return corresponding integral type for OFFSET_TYPE in range_check_type [PR101162] Date: Tue, 22 Jun 2021 13:23:58 +0000 (GMT) [thread overview] Message-ID: <20210622132358.ADF383857012@sourceware.org> (raw) https://gcc.gnu.org/g:92d9c9e705f039f42734139c233202888d2bf01b commit r12-1726-g92d9c9e705f039f42734139c233202888d2bf01b Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Jun 22 15:20:14 2021 +0200 fold-const: Return corresponding integral type for OFFSET_TYPE in range_check_type [PR101162] Andrew's recent r12-1608-g2f1686ff70b25fceb04ca2ffc0a450fb682913ef change to fail verification on various unary and binary operations with OFFSET_TYPE revealed that e.g. switchconv happily performs multiplications and additions in OFFSET_TYPE. 2021-06-22 Jakub Jelinek <jakub@redhat.com> Andrew Pinski <apinski@marvell.com> PR tree-optimization/101162 * fold-const.c (range_check_type): Handle OFFSET_TYPE like pointer types. * g++.dg/opt/pr101162.C: New test. Diff: --- gcc/fold-const.c | 2 +- gcc/testsuite/g++.dg/opt/pr101162.C | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 95673d24ed0..0b33ee99a81 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5360,7 +5360,7 @@ range_check_type (tree etype) else return NULL_TREE; } - else if (POINTER_TYPE_P (etype)) + else if (POINTER_TYPE_P (etype) || TREE_CODE (etype) == OFFSET_TYPE) etype = unsigned_type_for (etype); return etype; } diff --git a/gcc/testsuite/g++.dg/opt/pr101162.C b/gcc/testsuite/g++.dg/opt/pr101162.C new file mode 100644 index 00000000000..40321890bb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr101162.C @@ -0,0 +1,21 @@ +// PR tree-optimization/101162 +// { dg-do compile } +// { dg-options "-O2" } + +struct A { int i1, i2, i3, i4, i5, i6; }; + +int A::* +foo (int i) +{ + switch (i) + { + case 1: return &A::i1; + case 2: return &A::i2; + case 3: return &A::i3; + case 4: return &A::i4; + case 5: return &A::i5; + case 6: return &A::i6; + } + + return 0; +}
reply other threads:[~2021-06-22 13:23 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=20210622132358.ADF383857012@sourceware.org \ --to=jakub@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).