This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/70600] Missed tree optimization with multiple additions in different types.
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Jul 2016 07:24:47 +0000
- Subject: [Bug tree-optimization/70600] Missed tree optimization with multiple additions in different types.
- Auto-submitted: auto-generated
- References: <bug-70600-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70600
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Note I think FRE handles the above incorrectly as it converts the safe
> unsigned addition to non safe signed addition. I will file a different bug
> about that issue.
Actually I messed up the testcase and there is no bug there :).
But we do need FRE to handle this case rather than just reassoicate:
int f(int a, int b, int d)
{
unsigned a1 = a;
unsigned b1 = b;
unsigned c1 = a1 + b1;
if (a <= 0 || b <= 0)
return 0;
int c = c1;
if (d)
c = a + b;
return c;
}
--- CUT ----
We should also handle cases where the lower sizes are done too (just need to
truncate inside the if). I have seen both of these before in real code.