public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/33779] [4.3 Regression] folds unsigned multiplication == 0 to true
Date: Sat, 27 Oct 2007 17:29:00 -0000	[thread overview]
Message-ID: <20071027172925.1974.qmail@sourceware.org> (raw)
In-Reply-To: <bug-33779-10053@http.gcc.gnu.org/bugzilla/>



------- Comment #6 from rguenth at gcc dot gnu dot org  2007-10-27 17:29 -------
"This goes wrong in extract_muldiv..."

sorry for not pasting my complete analysis (actually the testcase is carefuly
crafted from looking at this code ;)).  The recursion through conversions

    case CONVERT_EXPR:  case NON_LVALUE_EXPR:  case NOP_EXPR:
      /* If op0 is an expression ...  */
      if ((COMPARISON_CLASS_P (op0)
           || UNARY_CLASS_P (op0)
           || BINARY_CLASS_P (op0)
           || VL_EXP_CLASS_P (op0)
           || EXPRESSION_CLASS_P (op0))
          /* ... and is unsigned, and its type is smaller than ctype,
             then we cannot pass through as widening.  */
          && ((TYPE_UNSIGNED (TREE_TYPE (op0))
               && ! (TREE_CODE (TREE_TYPE (op0)) == INTEGER_TYPE
                     && TYPE_IS_SIZETYPE (TREE_TYPE (op0)))
               && (GET_MODE_SIZE (TYPE_MODE (ctype))
                   > GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0)))))
              /* ... or this is a truncation (t is narrower than op0),
                 then we cannot pass through this narrowing.  */
              || (GET_MODE_SIZE (TYPE_MODE (type))
                  < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0))))
              /* ... or signedness changes for division or modulus,
                 then we cannot pass through this conversion.  */
              || (code != MULT_EXPR
                  && (TYPE_UNSIGNED (ctype)
                      != TYPE_UNSIGNED (TREE_TYPE (op0))))))
        break;

      /* Pass the constant down and see if we can make a simplification.  If
         we can, replace this expression with the inner simplification for
         possible later conversion to our or some other type.  */
      if ((t2 = fold_convert (TREE_TYPE (op0), c)) != 0
          && TREE_CODE (t2) == INTEGER_CST
          && !TREE_OVERFLOW (t2)
          && (0 != (t1 = extract_muldiv (op0, t2, code,
                                         code == MULT_EXPR
                                         ? ctype : NULL_TREE,
                                         strict_overflow_p))))
        return t1;
      break;

is wrong as it might convert the transformation from one in unsigned type
to one in signed type.


-- 


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


  parent reply	other threads:[~2007-10-27 17:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-15 13:13 [Bug middle-end/33779] New: " rguenth at gcc dot gnu dot org
2007-10-15 13:24 ` [Bug middle-end/33779] " rguenth at gcc dot gnu dot org
2007-10-15 13:31 ` rguenth at gcc dot gnu dot org
2007-10-15 13:32 ` rguenth at gcc dot gnu dot org
2007-10-19 16:31 ` janis at gcc dot gnu dot org
2007-10-22  8:43 ` pinskia at gcc dot gnu dot org
2007-10-27 16:43 ` tromey at gcc dot gnu dot org
2007-10-27 17:29 ` rguenth at gcc dot gnu dot org [this message]
2007-10-27 17:30 ` rguenth at gcc dot gnu dot org
2007-10-31 12:33 ` rguenth at gcc dot gnu dot org
2007-10-31 12:34 ` rguenth at gcc dot gnu dot 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=20071027172925.1974.qmail@sourceware.org \
    --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).