From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15490 invoked by alias); 18 Aug 2005 23:51:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 15358 invoked by uid 48); 18 Aug 2005 23:50:40 -0000 Date: Fri, 19 Aug 2005 01:03:00 -0000 From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050818235036.23471.pinskia@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug tree-optimization/23471] New: a*a (for signed ints with -fno-wrapv) is always postive X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg02159.txt.bz2 List-Id: 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