public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14490] New: [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
@ 2004-03-08 20:42 kazu at cs dot umass dot edu
  2004-03-08 20:45 ` [Bug optimization/14490] " pinskia at gcc dot gnu dot org
  2004-05-17 17:47 ` [Bug tree-optimization/14490] " pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 14+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-03-08 20:42 UTC (permalink / raw)
  To: gcc-bugs

Consider:

void bar (void);

void
foo (int a)
{
  if (a < 100)
    return;
  if (200 < a)
    return;

  if (a - 10 > 150)
    bar ();
}

We know that "a" is between 100 and 200 after the first two ifs.
So we should be able to simplify "a - 10 > 150" into "a > 160".
Here is what I get:

foo (a)
{
  int T.0;

<bb 0>:
  if (a <= 99) goto <L0>; else goto <L1>;

<L0>:;
  return;

<L1>:;
  if (a > 200) goto <L2>; else goto <L3>;

<L2>:;
  return;

<L3>:;
  if (a - 10 > 150) goto <L4>; else goto <L5>;

<L4>:;
  bar () [tail call];

<L5>:;
  return;

}

-- 
           Summary: [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
  2004-03-08 20:42 [Bug optimization/14490] New: [tree-ssa] Simplify "a - 10 > 150" into "a > 160" kazu at cs dot umass dot edu
@ 2004-03-08 20:45 ` pinskia at gcc dot gnu dot org
  2004-05-17 17:47 ` [Bug tree-optimization/14490] " pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-08 20:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-08 20:45 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-08 20:45:01
               date|                            |
   Target Milestone|---                         |tree-ssa


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
  2004-03-08 20:42 [Bug optimization/14490] New: [tree-ssa] Simplify "a - 10 > 150" into "a > 160" kazu at cs dot umass dot edu
  2004-03-08 20:45 ` [Bug optimization/14490] " pinskia at gcc dot gnu dot org
@ 2004-05-17 17:47 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-17 17:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-17 01:46 -------
Fold is not doing this optimization.  PR 15459 is not really needed for this but it still will 
be needed for other cases where a variable is used instead of the expression a-10.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <bug-14490-4@http.gcc.gnu.org/bugzilla/>
@ 2014-10-31  4:04 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31  4:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14490
Bug 14490 depends on bug 15459, which changed state.

Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (8 preceding siblings ...)
  2005-07-02 16:25 ` pinskia at gcc dot gnu dot org
@ 2005-08-17  3:10 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-17  3:10 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 14490 depends on bug 22236, which changed state.

Bug 22236 Summary: [4.1 Regression] wrong code for casts and scev
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22236

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (7 preceding siblings ...)
  2005-07-02 16:25 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-02 16:25 ` pinskia at gcc dot gnu dot org
  2005-08-17  3:10 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-02 16:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-02 16:25 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (6 preceding siblings ...)
  2005-06-30 19:13 ` pinskia at gcc dot gnu dot org
@ 2005-07-02 16:25 ` cvs-commit at gcc dot gnu dot org
  2005-07-02 16:25 ` pinskia at gcc dot gnu dot org
  2005-08-17  3:10 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-02 16:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-02 16:25 -------
Subject: Bug 14490

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-07-02 16:24:31

Modified files:
	gcc            : ChangeLog fold-const.c 
Added files:
	gcc/testsuite/gcc.dg: 20050702-1.c 
	gcc/testsuite/gcc.dg/tree-ssa: pr14490-1.c pr14490-2.c 
	                               pr14490-3.c pr14490-4.c 

Log message:
	2005-07-02  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/14490
	* fold-const.c (fold_binary): Handle the return value of
	fold_to_nonsharp_ineq_using_bound if we get back the same operand back.
	Implement "X +- C1 CMP C2" folding to "X CMP C2 -+ C1".

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9317&r2=2.9318
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.599&r2=1.600
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20050702-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr14490-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr14490-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr14490-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr14490-4.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (5 preceding siblings ...)
  2005-06-30  6:03 ` pinskia at gcc dot gnu dot org
@ 2005-06-30 19:13 ` pinskia at gcc dot gnu dot org
  2005-07-02 16:25 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30 19:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 19:13 -------
Patch posted here: <http://gcc.gnu.org/ml/gcc-patches/2005-06/msg02249.html>.  This might 
improve code gen in SPEC but since I have not tried, I don't know but I know that Richard Earnshaw was 
asking about this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |06/msg02249.html
           Keywords|                            |patch


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (4 preceding siblings ...)
  2005-06-30  4:42 ` pinskia at gcc dot gnu dot org
@ 2005-06-30  6:03 ` pinskia at gcc dot gnu dot org
  2005-06-30 19:13 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30  6:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 06:03 -------
(In reply to comment #7)
> And I found another latent bug which makes it impossible to bootstrap GCC :(
Oh, I found a simple patch which fixes that, bootstrapping the fix with the fix for this bug.

-- 


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (3 preceding siblings ...)
  2005-06-29 20:57 ` pinskia at gcc dot gnu dot org
@ 2005-06-30  4:42 ` pinskia at gcc dot gnu dot org
  2005-06-30  6:03 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30  4:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 04:42 -------
And I found another latent bug which makes it impossible to bootstrap GCC :(
Here is a short testcase for that bug:
_Bool f();
void g(int);
void h (int old_size)
{
  int new_size = old_size, i;
  g(old_size - 1);      
  i = 0;
  while (i < old_size - 1)
  {
    if (f())
    {
      i++;
      continue;
    }
    while (i < old_size - 1)
      i++;
  }
  g(new_size);
}


-- 


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
                   ` (2 preceding siblings ...)
  2005-06-29 20:07 ` pinskia at gcc dot gnu dot org
@ 2005-06-29 20:57 ` pinskia at gcc dot gnu dot org
  2005-06-30  4:42 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-29 20:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-29 20:57 -------
I found a bug which my patch will make latent (PR 22236).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |22236


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
  2005-06-29 19:38 ` pinskia at gcc dot gnu dot org
  2005-06-29 20:06 ` pinskia at gcc dot gnu dot org
@ 2005-06-29 20:07 ` pinskia at gcc dot gnu dot org
  2005-06-29 20:57 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-29 20:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-29 20:07 -------
(In reply to comment #4)
> Actually since overflow is undefined we can do this no matter what at least for signed types.
And when -fwrapv is not supplied.

-- 


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
  2005-06-29 19:38 ` pinskia at gcc dot gnu dot org
@ 2005-06-29 20:06 ` pinskia at gcc dot gnu dot org
  2005-06-29 20:07 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-29 20:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-29 20:05 -------
Actually since overflow is undefined we can do this no matter what at least for signed types.

-- 


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


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

* [Bug tree-optimization/14490] [tree-ssa] Simplify "a - 10 > 150" into "a > 160"
       [not found] <20040308204220.14490.kazu@gcc.gnu.org>
@ 2005-06-29 19:38 ` pinskia at gcc dot gnu dot org
  2005-06-29 20:06 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-29 19:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-29 19:37 -------
I think I have a fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

end of thread, other threads:[~2014-10-31  4:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-08 20:42 [Bug optimization/14490] New: [tree-ssa] Simplify "a - 10 > 150" into "a > 160" kazu at cs dot umass dot edu
2004-03-08 20:45 ` [Bug optimization/14490] " pinskia at gcc dot gnu dot org
2004-05-17 17:47 ` [Bug tree-optimization/14490] " pinskia at gcc dot gnu dot org
     [not found] <20040308204220.14490.kazu@gcc.gnu.org>
2005-06-29 19:38 ` pinskia at gcc dot gnu dot org
2005-06-29 20:06 ` pinskia at gcc dot gnu dot org
2005-06-29 20:07 ` pinskia at gcc dot gnu dot org
2005-06-29 20:57 ` pinskia at gcc dot gnu dot org
2005-06-30  4:42 ` pinskia at gcc dot gnu dot org
2005-06-30  6:03 ` pinskia at gcc dot gnu dot org
2005-06-30 19:13 ` pinskia at gcc dot gnu dot org
2005-07-02 16:25 ` cvs-commit at gcc dot gnu dot org
2005-07-02 16:25 ` pinskia at gcc dot gnu dot org
2005-08-17  3:10 ` pinskia at gcc dot gnu dot org
     [not found] <bug-14490-4@http.gcc.gnu.org/bugzilla/>
2014-10-31  4:04 ` pinskia at gcc dot gnu.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).