public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/23471] New: a*a (for signed ints with -fno-wrapv) is always postive
@ 2005-08-19 1:03 pinskia at gcc dot gnu dot org
2005-08-31 16:18 ` [Bug tree-optimization/23471] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-19 1:03 UTC (permalink / raw)
To: gcc-bugs
Hmm, this is both a VRP bug and a folding bug. Even though a is VARYING, we know the that a*a will
always be postive (this with -fno-wrapv which is default for C, C++ and fortran).
void link_error(void);
void f(int a)
{
int b = a;
b*=a;
if (b < 0)
link_error();
}
---
There should be no references to link_error().
There is another way of fixing this via the fold:
void link_error(void);
void f(int a)
{
if (a*a < 0)
link_error();
}
But that will miss:
void link_error(void);
void f(int a)
{
if (a*a*a*a*a*a < 0)
link_error();
}
---
Yes that is most likely to overflow but that is the whole point of -fno-wrapv.
Also ICC does not do this optimization at all.
--
Summary: a*a (for signed ints with -fno-wrapv) is always postive
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23471
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-01 2:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-23471-6528@http.gcc.gnu.org/bugzilla/>
2006-03-01 2:54 ` [Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive pinskia at gcc dot gnu dot org
2005-08-19 1:03 [Bug tree-optimization/23471] New: " pinskia at gcc dot gnu dot org
2005-08-31 16:18 ` [Bug tree-optimization/23471] " pinskia at gcc dot gnu dot org
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).