[Bug tree-optimization/50717] [4.7 Regression] Silent code gen fault with incorrect widening of multiply

ams at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Oct 14 15:26:00 GMT 2011


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.



More information about the Gcc-bugs mailing list