public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/66375] [4.8/4.9/5 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
Date: Tue, 02 Jun 2015 10:31:00 -0000	[thread overview]
Message-ID: <bug-66375-4-k3SKN4olgV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66375-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66375

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hum.

  <bb 5>:
  # prephitmp_22 = PHI <0(4), c.2_15(10)>
...
  e_12 = (char) prephitmp_22;
  _13 = (int) e_12;
...
  c.2_15 = _13 + -11;

Simulating statement (from ssa_edges): prephitmp_22 = PHI <0(4), c.2_15(10)>

Visiting PHI node: prephitmp_22 = PHI <0(4), c.2_15(10)>
    Argument #0 (4 -> 5 executable)
        0: [0, 0]
    Argument #1 (10 -> 5 executable)
        c.2_15: [-22, -11]
Meeting
  [0, 0]
and
  [-22, -11]
to
  [-22, 0]
...
Found new range for prephitmp_22: [-2147483647, 0]

...

Visiting statement:
_13 = (int) e_12;
Intersecting
  [-128, 127]
and
  [-128, 127]
to
  [-128, 127]
Found new range for _13: [-128, 127]
marking stmt to be not simulated again

Simulating statement (from ssa_edges): c.2_15 = _13 + -11;

Visiting statement:
c.2_15 = _13 + -11;
Found new range for c.2_15: [-139, 116]
marking stmt to be not simulated again

Simulating statement (from ssa_edges): prephitmp_22 = PHI <0(4), c.2_15(10)>

Visiting PHI node: prephitmp_22 = PHI <0(4), c.2_15(10)>
    Argument #0 (4 -> 5 executable)
        0: [0, 0]
    Argument #1 (10 -> 5 executable)
        c.2_15: [-139, 116]
Meeting
  [0, 0]
and
  [-139, 116]
to
  [-139, 116]
marking stmt to be not simulated again

(note no "Found new range for prephitmp_22" here!)

Value ranges after VRP:

prephitmp_22: [-2147483647, 0]

oops.

This seems to be because we drop to [-2147483647, 2147483646] but then
adjust_range_with_scev computes {0, +, -11}_1 for _22  which is obviously
wrong.

It looks like the CHREC gets built from

static t_bool
follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
                        tree type, tree rhs0, enum tree_code code, tree rhs1,
                        gphi *halting_phi, tree *evolution_of_loop,
                        int limit)
{
...
  switch (code)
    {
    case POINTER_PLUS_EXPR:
    case PLUS_EXPR:
      if (TREE_CODE (rhs0) == SSA_NAME)
        {
          if (TREE_CODE (rhs1) == SSA_NAME)
            {
...
          else
            {
              /* Match an assignment under the form:
                 "a = b + ...".  */
              res = follow_ssa_edge
                (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                 evolution_of_loop, limit);
              if (res == t_true)
                *evolution_of_loop = add_to_evolution
                  (loop->num, chrec_convert (type, *evolution_of_loop,
                                             at_stmt),
                   code, rhs1, at_stmt);

and what goes wrong is follow_ssa_edge skipping the (unsigned char) truncation.

Still digging...


  parent reply	other threads:[~2015-06-02 10:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02  5:43 [Bug tree-optimization/66375] New: " su at cs dot ucdavis.edu
2015-06-02  5:49 ` [Bug middle-end/66375] " pinskia at gcc dot gnu.org
2015-06-02  6:16 ` [Bug middle-end/66375] [4.8/4.9/5 Regression] " jakub at gcc dot gnu.org
2015-06-02  8:50 ` rguenth at gcc dot gnu.org
2015-06-02  9:31 ` rguenth at gcc dot gnu.org
2015-06-02 10:31 ` rguenth at gcc dot gnu.org [this message]
2015-06-02 11:21 ` rguenth at gcc dot gnu.org
2015-06-02 11:56 ` rguenth at gcc dot gnu.org
2015-06-02 14:34 ` rguenth at gcc dot gnu.org
2015-06-03  7:57 ` [Bug middle-end/66375] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org
2015-06-09 23:55 ` bernhard.kaindl at thalesgroup dot com
2015-06-10  7:01 ` [Bug middle-end/66375] [4.8/4.9/5 " rguenth at gcc dot gnu.org
2015-06-18 14:04 ` rguenth at gcc dot gnu.org
2015-06-23  8:28 ` [Bug middle-end/66375] [4.8/4.9 " rguenth at gcc dot gnu.org
2015-06-26 20:04 ` [Bug middle-end/66375] [4.9 " jakub at gcc dot gnu.org
2015-06-26 20:32 ` jakub at gcc dot gnu.org
2022-10-25 11:40 ` cvs-commit 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-66375-4-k3SKN4olgV@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).