Linux-Sparse Archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [SPARSE 0/4] fix/improve canonicalization of signed compares
Date: Sun, 18 Apr 2021 17:32:29 +0200	[thread overview]
Message-ID: <20210418153233.45234-1-luc.vanoostenryck@gmail.com> (raw)

This series contains the following:
1) signed compares against a constant are now canonicalized towards 0
   so that (x >= 0) doesn't become (x > -1)
2) a signed compare like (x >= 0 && x <= C) is simplified into the
   unsigned compare: (x <= C)
   
This series is also available for review and testing at:
  git://git.kernel.org/pub/scm/devel/sparse/sparse.git optim-and-cmp

Luc Van Oostenryck (4):
  canonicalize constant signed compares toward zero
  add testcases for AND(x > 0, x <= C) --> x u<= C
  add helper is_positive()
  simplify AND(x >= 0, x < C) --> (unsigned)x < C

 linearize.h                           |  5 ++
 simplify.c                            | 45 +++++++++++++---
 validation/optim/canonical-cmp-zero.c | 74 +++++++++++++++++++++++++++
 validation/optim/range-check1.c       | 16 ++++++
 validation/optim/range-check2.c       | 14 +++++
 5 files changed, 148 insertions(+), 6 deletions(-)
 create mode 100644 validation/optim/canonical-cmp-zero.c
 create mode 100644 validation/optim/range-check1.c
 create mode 100644 validation/optim/range-check2.c


base-commit: eb4cdd21b7d0cedbbeff7f70e24473706ccce5a6
-- 
2.31.1


             reply	other threads:[~2021-04-18 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-18 15:32 Luc Van Oostenryck [this message]
2021-04-18 15:32 ` [SPARSE 1/4] canonicalize constant signed compares toward zero Luc Van Oostenryck
2021-04-18 15:32 ` [SPARSE 2/4] add testcases for AND(x > 0, x <= C) --> x u<= C Luc Van Oostenryck
2021-04-18 15:32 ` [SPARSE 3/4] add helper is_positive() Luc Van Oostenryck
2021-04-18 15:32 ` [SPARSE 4/4] simplify AND(x >= 0, x < C) --> (unsigned)x < C Luc Van Oostenryck

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=20210418153233.45234-1-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).