This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/50717] [4.7 Regression] Silent code gen fault with incorrect widening of multiply
- From: "ams at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Oct 2011 15:25:49 +0000
- Subject: [Bug tree-optimization/50717] [4.7 Regression] Silent code gen fault with incorrect widening of multiply
- Auto-submitted: auto-generated
- References: <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.