[Bug middle-end/70920] New: if ((intptr_t)ptr == 0) doesn't get simplified to if (ptr == 0)
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 3 03:33:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70920
Bug ID: 70920
Summary: if ((intptr_t)ptr == 0) doesn't get simplified to if
(ptr == 0)
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
In the following test case, the call to baz remains in the final optimized code
even though it's dead code.
#include <stdint.h>
void bar (void);
void baz (void);
void
foo (int *a)
{
if ((intptr_t)a == 0)
{
bar ();
if (a)
baz ();
}
}
Should also be able to optimize compares against non-zero constants, e.g.
void
foo (int *a)
{
if ((intptr_t)a == 5)
{
bar ();
if (a != (int *)5)
baz ();
}
}
More information about the Gcc-bugs
mailing list