public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amker.cheng at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/53922] New: VRP: semantic conflict between range_includes_zero_p and value_inside_range
Date: Wed, 11 Jul 2012 06:21:00 -0000	[thread overview]
Message-ID: <bug-53922-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53922

             Bug #: 53922
           Summary: VRP: semantic conflict between range_includes_zero_p
                    and value_inside_range
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amker.cheng@gmail.com


In tree-vrp.c
function value_inside_range returns:
          1 if VAL is inside value range VR (VR->MIN <= VAL <= VR->MAX),
          0 if VAL is not inside VR,
     -2 if we cannot tell either way.

While in function range_includes_zero_p, it:
         return (value_inside_range (zero, vr) == 1);
which is bogus.
Because when value_inside_range returns -2, there is the possibility that value
range includes zero.

For example:

int x(int a)
{
    return a;
}
int y(int a) __attribute__ ((weak));
int (*scan_func)(int);
extern int g;
int g = 0;
int main()
{
    if (g)
        scan_func = x;
    else
        scan_func = y;

    if (scan_func)
        g = scan_func(10);

    return 0;
}

compiled with command line:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -Os -S test.c -o test.S
-fdump-tree-all

The dump of vrp2 pass is:
main ()
{
  int (*<Tcc0>) (int) cstore.6;
  int g.2;
  int g.0;

<bb 2>:
  g.0_1 = g;
  if (g.0_1 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:

<bb 4>:
  # cstore.6_9 = PHI <x(3), y(2)>
  scan_func = cstore.6_9;
  g.2_4 = cstore.6_9 (10);
  g = g.2_4;
  return 0;

}

Though the problem shows up with this case in gcc4.6 branch and -Os option on
arm, I think it exists in 4.7/4.8 too, just concealed by different gimple
statements.

I will work out a patch for this.


             reply	other threads:[~2012-07-11  6:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11  6:21 amker.cheng at gmail dot com [this message]
2012-07-11  7:36 ` [Bug middle-end/53922] " rguenth at gcc dot gnu.org
2012-07-11  8:03 ` amker.cheng at gmail dot com
2012-07-11 10:12 ` amker.cheng at gmail dot com
2012-07-11 11:36 ` [Bug tree-optimization/53922] " rguenth at gcc dot gnu.org
2012-07-11 12:29 ` rguenth at gcc dot gnu.org
2012-07-13  9:56 ` [Bug tree-optimization/53922] [4.6/4.7/4.8 Regression] " rguenth at gcc dot gnu.org
2012-07-13 11:22 ` rguenth at gcc dot gnu.org
2012-07-13 11:41 ` [Bug tree-optimization/53922] [4.6/4.7 " rguenth at gcc dot gnu.org
2012-09-07  9:44 ` rguenth at gcc dot gnu.org
2012-09-07 13:05 ` rguenth at gcc dot gnu.org
2012-09-07 13:06 ` [Bug tree-optimization/53922] [4.6 " rguenth at gcc dot gnu.org
2012-09-22 23:46 ` howarth at nitro dot med.uc.edu
2012-09-23 10:32 ` dominiq at lps dot ens.fr
2012-09-27 21:28 ` fang at csl dot cornell.edu
2013-04-12 16:27 ` jakub at gcc dot gnu.org

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=bug-53922-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).