public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/20922] New: missed always false conditional
@ 2005-04-09 21:36 pinskia at gcc dot gnu dot org
2005-04-10 21:02 ` [Bug tree-optimization/20922] " pinskia at gcc dot gnu dot org
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-09 21:36 UTC (permalink / raw)
To: gcc-bugs
The following function should just "return 1":
int f(int i)
{
int i1 = i -2;
if (i1 > i)
return 0;
return 1;
}
We miss this on the tree level, I found this while look into the following fortran code:
SUBROUTINE d ( a, b,n)
IMPLICIT NONE
INTEGER :: n
REAL,DIMENSION(n) :: a
REAL,DIMENSION(n) :: b
b(n-2:n) = sqrt(a(n-2:n))
END SUBROUTINE d
In final_cleanup, we have:
D.679 = *n;
S.2 = D.679 - 2;
if (D.679 < S.2) goto L.1; else goto <L7>;
--
Summary: missed always false conditional
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
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=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
@ 2005-04-10 21:02 ` pinskia at gcc dot gnu dot org
2005-04-10 21:03 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-10 21:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-10 21:02 -------
Reduced testcase showing fold does not do it:
int f(int i)
{
return (i - 2) > i;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
2005-04-10 21:02 ` [Bug tree-optimization/20922] " pinskia at gcc dot gnu dot org
@ 2005-04-10 21:03 ` pinskia at gcc dot gnu dot org
2005-04-10 21:06 ` pinskia at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-10 21:03 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |19986
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
2005-04-10 21:02 ` [Bug tree-optimization/20922] " pinskia at gcc dot gnu dot org
2005-04-10 21:03 ` pinskia at gcc dot gnu dot org
@ 2005-04-10 21:06 ` pinskia at gcc dot gnu dot org
2005-04-10 22:00 ` kazu at cs dot umass dot edu
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-10 21:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-10 21:06 -------
This is not caught untill RTL combine.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-04-10 21:06 ` pinskia at gcc dot gnu dot org
@ 2005-04-10 22:00 ` kazu at cs dot umass dot edu
2005-04-10 23:43 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-04-10 22:00 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |kazu at cs dot umass dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-04-10 22:00 ` kazu at cs dot umass dot edu
@ 2005-04-10 23:43 ` pinskia at gcc dot gnu dot org
2005-04-11 19:50 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-10 23:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-10 23:43 -------
Note this is only true with -fno-wrapv (which is default for C and C++ and I think Fortran too but not
Java).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-04-10 23:43 ` pinskia at gcc dot gnu dot org
@ 2005-04-11 19:50 ` pinskia at gcc dot gnu dot org
2005-04-16 17:12 ` phython at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-11 19:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-11 19:49 -------
Confirmed, the code which does this on the RTL level is in simplify_const_relational_operation.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-04-11 19:49:49
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-04-11 19:50 ` pinskia at gcc dot gnu dot org
@ 2005-04-16 17:12 ` phython at gcc dot gnu dot org
2005-04-18 15:18 ` cvs-commit at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: phython at gcc dot gnu dot org @ 2005-04-16 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From phython at gcc dot gnu dot org 2005-04-16 17:12 -------
Created an attachment (id=8654)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8654&action=view)
Fold stuff
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |phython at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-04-16 17:12 ` phython at gcc dot gnu dot org
@ 2005-04-18 15:18 ` cvs-commit at gcc dot gnu dot org
2005-04-18 15:20 ` phython at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-04-18 15:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-04-18 15:18 -------
Subject: Bug 20922
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: phython@gcc.gnu.org 2005-04-18 15:18:22
Modified files:
gcc : ChangeLog fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.dg: pr20922-1.c pr20922-2.c pr20922-3.c
pr20922-4.c pr20922-5.c pr20922-6.c
Log message:
2005-04-18 James A. Morrison <phython@gcc.gnu.org>
PR tree-optimization/20922
* fold-const.c (fold_binary): Fold X - c > X and X + c < X to false.
Fold X + c >= X and fold X - c <= X to true.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8345&r2=2.8346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.562&r2=1.563
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5364&r2=1.5365
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-4.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-5.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20922-6.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (7 preceding siblings ...)
2005-04-18 15:18 ` cvs-commit at gcc dot gnu dot org
@ 2005-04-18 15:20 ` phython at gcc dot gnu dot org
2005-04-18 15:38 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: phython at gcc dot gnu dot org @ 2005-04-18 15:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From phython at gcc dot gnu dot org 2005-04-18 15:20 -------
Fixed in the last commit.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (8 preceding siblings ...)
2005-04-18 15:20 ` phython at gcc dot gnu dot org
@ 2005-04-18 15:38 ` pinskia at gcc dot gnu dot org
2005-04-25 0:38 ` markus at oberhumer dot com
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18 15:38 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (9 preceding siblings ...)
2005-04-18 15:38 ` pinskia at gcc dot gnu dot org
@ 2005-04-25 0:38 ` markus at oberhumer dot com
2005-04-25 0:40 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: markus at oberhumer dot com @ 2005-04-25 0:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From markus at oberhumer dot com 2005-04-25 00:38 -------
Is this optimization really legal in C/C++? Could some language lawyer look at
this (and check the output when compiling with -O3):
#include <limits.h>
int f1(int i) { return (i - 2) > i; }
int f2(int i) { return (i + 2) > i; }
int g1(void) { return f1(INT_MIN); }
int g2(void) { return f2(INT_MAX); }
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (10 preceding siblings ...)
2005-04-25 0:38 ` markus at oberhumer dot com
@ 2005-04-25 0:40 ` pinskia at gcc dot gnu dot org
2005-04-25 0:42 ` jim dot morrison at gmail dot com
2005-04-25 1:01 ` markus at oberhumer dot com
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 0:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 00:40 -------
(In reply to comment #15)
> Is this optimization really legal in C/C++? Could some language lawyer look at
> this (and check the output when compiling with -O3):
Overflow/Underflow of signed operands in C/C++ is undefined, now in Java it is not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (11 preceding siblings ...)
2005-04-25 0:40 ` pinskia at gcc dot gnu dot org
@ 2005-04-25 0:42 ` jim dot morrison at gmail dot com
2005-04-25 1:01 ` markus at oberhumer dot com
13 siblings, 0 replies; 15+ messages in thread
From: jim dot morrison at gmail dot com @ 2005-04-25 0:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jim dot morrison at gmail dot com 2005-04-25 00:42 -------
Subject: Re: missed always false conditional
On 25 Apr 2005 00:39:23 -0000, markus at oberhumer dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> --
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |markus at oberhumer dot com
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
The overflow semantics are undefined for signed types in C/C++.
Try with -ftrapv or -fwrapv if you need defined semantics for C/C++.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug tree-optimization/20922] missed always false conditional
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
` (12 preceding siblings ...)
2005-04-25 0:42 ` jim dot morrison at gmail dot com
@ 2005-04-25 1:01 ` markus at oberhumer dot com
13 siblings, 0 replies; 15+ messages in thread
From: markus at oberhumer dot com @ 2005-04-25 1:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From markus at oberhumer dot com 2005-04-25 01:01 -------
Ah, many thanks for the clarification. Still it's somewhat confusing that f1()
and g1() don't agree after inlining, but "undefined" probably means exactly that...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20922
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2005-04-25 1:01 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-09 21:36 [Bug tree-optimization/20922] New: missed always false conditional pinskia at gcc dot gnu dot org
2005-04-10 21:02 ` [Bug tree-optimization/20922] " pinskia at gcc dot gnu dot org
2005-04-10 21:03 ` pinskia at gcc dot gnu dot org
2005-04-10 21:06 ` pinskia at gcc dot gnu dot org
2005-04-10 22:00 ` kazu at cs dot umass dot edu
2005-04-10 23:43 ` pinskia at gcc dot gnu dot org
2005-04-11 19:50 ` pinskia at gcc dot gnu dot org
2005-04-16 17:12 ` phython at gcc dot gnu dot org
2005-04-18 15:18 ` cvs-commit at gcc dot gnu dot org
2005-04-18 15:20 ` phython at gcc dot gnu dot org
2005-04-18 15:38 ` pinskia at gcc dot gnu dot org
2005-04-25 0:38 ` markus at oberhumer dot com
2005-04-25 0:40 ` pinskia at gcc dot gnu dot org
2005-04-25 0:42 ` jim dot morrison at gmail dot com
2005-04-25 1:01 ` markus at oberhumer dot com
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).