public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ams at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/50717] [4.7 Regression] Silent code gen fault with incorrect widening of multiply
Date: Fri, 14 Oct 2011 15:26:00 -0000	[thread overview]
Message-ID: <bug-50717-4-E8h1O9rOdC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50717-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Stubbs <ams at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-10-14
         AssignedTo|unassigned at gcc dot       |ams at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #5 from Andrew Stubbs <ams at gcc dot gnu.org> 2011-10-14 15:25:49 UTC ---
I think I've identified the issue.

Basically, we *want* to recognise cases like these:

  int
  f1 (signed char a, signed char b, int c)
  {
    return (short)(a * b) + c;
  }

  long long
  f2 (short a, short b, long long c)
  {
    return (a * b) + c;
  }

  long long
  f3 (char a, char b, long long c)
  {
    return (a * b) + c;
  }

These have an extend between the multiply and plus operations, and the old
implementation couldn't cope with that.

The problem is that I've all caught all the cases where the user wanted (or C
standard requires) that the multiply product be truncated.

The solution then is to only convert to widening multiply when we can prove the
operation will never overflow.

I'll post a patch soon.


  parent reply	other threads:[~2011-10-14 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 15:48 [Bug tree-optimization/50717] New: " mgretton at sourceware dot org
2011-10-13 15:49 ` [Bug tree-optimization/50717] " mgretton at sourceware dot org
2011-10-13 15:50 ` mgretton at sourceware dot org
2011-10-13 15:51 ` mgretton at sourceware dot org
2011-10-13 16:54 ` ams at gcc dot gnu.org
2011-10-14  9:29 ` [Bug tree-optimization/50717] [4.7 Regression] " rguenth at gcc dot gnu.org
2011-10-14 15:26 ` ams at gcc dot gnu.org [this message]
2011-10-15 21:29 ` ams at gcc dot gnu.org
2011-10-18 19:57 ` ams at gcc dot gnu.org
2011-10-19 14:41 ` ams 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-50717-4-E8h1O9rOdC@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).