public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16632] New: A couple fold-const.c optimizations are non-functional
@ 2004-07-19 18:05 trt at acm dot org
  2004-07-19 18:35 ` [Bug tree-optimization/16632] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: trt at acm dot org @ 2004-07-19 18:05 UTC (permalink / raw)
  To: gcc-bugs

In fold-const.c there are a couple of bitmask/comparision optimizations:
      /* If we have (A & C) == D where D & ~C != 0, convert this into 0.
and
      /* If we have (A | C) == D where C & ~D != 0, convert this into 0.

Sample C code:
  void subr (int i)
  {
    if ((i|3)  == 1) return; /* never taken */
    if ((i&4)  == 2) return; /* never taken */
  }


Unfortunately fold-const.c neglects to fold ~C (~D) and so
the detection of these cases is non-functional.
I'm not sure how to demonstrate this outside the debugger,
since later pieces of gcc seem to clean this up.

For example ~D is computed on approx line 8391 with

                            build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1)));

This should be fold(build1 ...), or fold_not_const(arg1, TREE_TYPE(arg1)).
Similarly for ~C on approx line 8373.

-- 
           Summary: A couple fold-const.c optimizations are non-functional
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: trt at acm dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
@ 2004-07-19 18:35 ` pinskia at gcc dot gnu dot org
  2004-07-20 16:50 ` trt at acm dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-19 18:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-19 18:35 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
             Status|UNCONFIRMED                 |NEW
          Component|c                           |tree-optimization
     Ever Confirmed|                            |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-19 18:35:45
               date|                            |


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
  2004-07-19 18:35 ` [Bug tree-optimization/16632] " pinskia at gcc dot gnu dot org
@ 2004-07-20 16:50 ` trt at acm dot org
  2004-08-24 14:41 ` trt at acm dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: trt at acm dot org @ 2004-07-20 16:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From trt at acm dot org  2004-07-20 16:50 -------
Silly me, the demo code should have returned a value:
  int subr(int i)
  {
     if ((i|3)  == 1) return 1; /* never taken */
     if ((i&4)  == 2) return 1; /* never taken */
     return 0;
  }
This should simplify to "return 0;" but the assembler code retains the 'or'
and 'and' even at high optimization levels.

-- 


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
  2004-07-19 18:35 ` [Bug tree-optimization/16632] " pinskia at gcc dot gnu dot org
  2004-07-20 16:50 ` trt at acm dot org
@ 2004-08-24 14:41 ` trt at acm dot org
  2004-10-03 14:43 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: trt at acm dot org @ 2004-08-24 14:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From trt at acm dot org  2004-08-24 14:41 -------
Could someone please review and apply this patch?
In my opinion, the problem and patch are quite straightforward.

-- 


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
                   ` (2 preceding siblings ...)
  2004-08-24 14:41 ` trt at acm dot org
@ 2004-10-03 14:43 ` pinskia at gcc dot gnu dot org
  2004-10-03 15:33 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-03 14:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-03 14:43 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00194.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
                   ` (3 preceding siblings ...)
  2004-10-03 14:43 ` pinskia at gcc dot gnu dot org
@ 2004-10-03 15:33 ` cvs-commit at gcc dot gnu dot org
  2004-10-03 15:34 ` kazu at cs dot umass dot edu
  2004-10-15 17:15 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-03 15:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-03 15:33 -------
Subject: Bug 16632

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kazu@gcc.gnu.org	2004-10-03 15:33:21

Modified files:
	gcc            : ChangeLog 
	gcc/testsuite  : ChangeLog 

Log message:
	PR tree-optimization/16632
	* fold-const.c (fold) [EQ_EXPR]: When seeing if D & ~C != 0 to
	fold (A & C) == D into 0, fold ~C.  Similarly, for the case
	where | is used instead of &.
	
	PR tree-optimization/16632
	* testsuite/gcc.dg/tree-ssa/20041002-1.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5730&r2=2.5731
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4374&r2=1.4375



-- 


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
                   ` (4 preceding siblings ...)
  2004-10-03 15:33 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-03 15:34 ` kazu at cs dot umass dot edu
  2004-10-15 17:15 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-10-03 15:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-10-03 15:34 -------
Just checked in the fix.

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


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


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

* [Bug tree-optimization/16632] A couple fold-const.c optimizations are non-functional
  2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
                   ` (5 preceding siblings ...)
  2004-10-03 15:34 ` kazu at cs dot umass dot edu
@ 2004-10-15 17:15 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-15 17:15 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2004-10-15 17:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-19 18:05 [Bug c/16632] New: A couple fold-const.c optimizations are non-functional trt at acm dot org
2004-07-19 18:35 ` [Bug tree-optimization/16632] " pinskia at gcc dot gnu dot org
2004-07-20 16:50 ` trt at acm dot org
2004-08-24 14:41 ` trt at acm dot org
2004-10-03 14:43 ` pinskia at gcc dot gnu dot org
2004-10-03 15:33 ` cvs-commit at gcc dot gnu dot org
2004-10-03 15:34 ` kazu at cs dot umass dot edu
2004-10-15 17:15 ` 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).