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

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).