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; 3+ 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] 3+ messages in thread

* [Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive
  2005-08-19  1:03 [Bug tree-optimization/23471] New: a*a (for signed ints with -fno-wrapv) is always postive pinskia at gcc dot gnu dot org
@ 2005-08-31 16:18 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-31 16:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-31 16:07 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-31 16:07:00
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23471


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/23471] a*a (for signed ints with -fno-wrapv) is always postive
       [not found] <bug-23471-6528@http.gcc.gnu.org/bugzilla/>
@ 2006-03-01  2:54 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-01  2:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-01 02:54 -------
  b_3 = a_1 * a_1;
b_3: VARYING


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-12-07 03:01:04         |2006-03-01 02:54:17
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23471


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-01  2:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-19  1:03 [Bug tree-optimization/23471] New: a*a (for signed ints with -fno-wrapv) is always postive pinskia at gcc dot gnu dot org
2005-08-31 16:18 ` [Bug tree-optimization/23471] " pinskia at gcc dot gnu dot org
     [not found] <bug-23471-6528@http.gcc.gnu.org/bugzilla/>
2006-03-01  2:54 ` 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).