public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-2262] Add relation processing to ubsan builtins.
Date: Mon, 12 Jul 2021 23:41:42 +0000 (GMT)	[thread overview]
Message-ID: <20210712234142.9E20A3861C5A@sourceware.org> (raw)

https://gcc.gnu.org/g:9693ecdf7ed5dde9618d06560697ff8ee5e1e6b7

commit r12-2262-g9693ecdf7ed5dde9618d06560697ff8ee5e1e6b7
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Jul 12 14:38:42 2021 -0400

    Add relation processing to ubsan builtins.
    
    Ubsan builtins call the plus/minus/multiple fold routines, but did not
    use any relation information between the 2 operands that is available.
    query and pass any relations.
    This resolves gcc.dg/pr97505.c when operating in ranger-only mode.
    
            * gimple-range-fold.cc (fold_using_range::range_of_builtin_ubsan_call):
            Query relation between the 2 operands and use it.

Diff:
---
 gcc/gimple-range-fold.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 1fa4ace32b9..eff5d1f89f2 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -825,12 +825,14 @@ fold_using_range::range_of_builtin_ubsan_call (irange &r, gcall *call,
   tree arg1 = gimple_call_arg (call, 1);
   src.get_operand (ir0, arg0);
   src.get_operand (ir1, arg1);
+  // Check for any relation between arg0 and arg1.
+  relation_kind relation = src.query_relation (arg0, arg1);
 
   bool saved_flag_wrapv = flag_wrapv;
   // Pretend the arithmetic is wrapping.  If there is any overflow,
   // we'll complain, but will actually do wrapping operation.
   flag_wrapv = 1;
-  op->fold_range (r, type, ir0, ir1);
+  op->fold_range (r, type, ir0, ir1, relation);
   flag_wrapv = saved_flag_wrapv;
 
   // If for both arguments vrp_valueize returned non-NULL, this should


                 reply	other threads:[~2021-07-12 23:41 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=20210712234142.9E20A3861C5A@sourceware.org \
    --to=amacleod@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: 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).